java.lang.IllegalStateException: There is no body to invoke
with a Jenkins Pipeline that I was executing; this Pipeline executes whenever one commits new code into a GitHub Enterprise (GHE) repository, with a Pull Request.
To debug this further, I created a dummy GHE repository with a corresponding Jenkinsfile, and a new Jenkins pipeline.
This allowed me to
Without wishing to give away the plot, I'll TL;DR; and say that the problem was ME ( quelle surprise ).
Here's my initial Jenkinsfile: -
timestamps
{
node('linuxboxen')
checkout scm
def givenName = "Dave"
def familyName = "Hay"
withEnv(["GIVEN_NAME=${givenName}", "FAMILY_NAME=${familyName}"])
{
stage('JFDI')
{
sh '''#!/bin/bash
echo "Doing it"
echo $GIVEN_NAME
echo $FAMILY_NAME
'''
}
}
}
Can you see the problem ?
It took me a while ....
The node directive is NOT followed by a set of braces, meaning that nothing actually gets done, hence the exception.
The code SHOULD look like this: -
timestamps
{
node('linuxboxen')
{
checkout scm
def givenName = "Dave"
def familyName = "Hay"
withEnv(["GIVEN_NAME=${givenName}", "FAMILY_NAME=${familyName}"])
{
stage('JFDI')
{
sh '''#!/bin/bash
echo "Doing it"
echo $GIVEN_NAME
echo $FAMILY_NAME
'''
}
}
}
}
In other words, the node() directive needs something to do, hence the need for the braces, which can contain one or more stages(), plus associated directives.
Nice :-)
No comments:
Post a Comment