In Jenkins/Hudson, with the help of a Postbuild Groovy script, I would like to get one of the following:
At the moment I only found the following way, but it's rather limited:
def item = hudson.model.Hudson.instance.getItem("GroovyMultipleFailTest")
def build = item.getLastBuild()
build.getNumber()
On your Jenkins server, browse to /env-vars. html . On my localhost test server, the path is this: http://localhost:8080/env-vars.html/. That will give you a list of the environment variables available to your job.
Usage. To create Groovy-based project, add new free-style project and select "Execute Groovy script" in the Build section, select previously configured Groovy installation and then type your command, or specify your script file name.
Visit "Manage Jenkins" > "Manage Nodes". Select any node to view the status page. In the menu on the left, a menu item is available to open a "Script Console" on that specific agent.
${manager.build.getEnvironment(manager.listener)['BUILD_NUMBER'] }
Using Jenkins v2.17 this works for me:
echo "BUILD_NUMBER=${env.BUILD_NUMBER}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With