I am new to the build-flow-plugin and have been asked to add some steps to an existing job. While I have a shell script that does this, it was requested that I use the build-flow-plugin instead. I am familiar with Groovy as I use it to access information within jenkins, but the DSL/Groovy build flow plugin confuses me. Can someone explain to me how to grab a value from Jenkins, or a value that is currently being used in existing build-flow, and then go and use it in a later step after everything is completed to execute some action.
This is a reduced list of what is currently configured for the existing build flow
if (bParent.build.properties.environment['TOOL_CHANGE_MERGED'] == 'TRUE') {
parallel (
{build ("update_issue", EnvVarFile : bParent.build.properties.environment['ENV_VAR_FILE']) },
{build ("verify_commit_message", EnvVarFile : bParent.build.properties.environment['ENV_VAR_FILE']) })
These are the actions I have taken and I included a brief comment about each action.
println “${TOOL_BRANCH}” - my parameter from above
println “${BUILD_ID}” - Jenkins parameter
println “bParent.build.properties.environment['GIT_TREE']” - this is the directory I want to clean up from the ENV_VAR_FILE, however I can use a combination of other values, to obtain the same result
Whenever I try anything above or anything similar I get the following error. What am I missing?
ERROR: Failed to run DSL Script
groovy.lang.MissingPropertyException: No such property: TOOL_BRANCH for class: Script1
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
at Script1.run(Script1.groovy:42)
at Script1$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at Script1$run.call(Unknown Source)
at com.cloudbees.plugins.flow.FlowDSL.executeFlowScript(FlowDSL.groovy:84)
at com.cloudbees.plugins.flow.FlowRun$FlyweightTaskRunnerImpl.run(FlowRun.java:219)
at hudson.model.Run.execute(Run.java:1665)
at com.cloudbees.plugins.flow.FlowRun.run(FlowRun.java:155)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:246)
I’m thinking that this:
println “${TOOL_BRANCH}”
needs to be this:
println params[‘TOOL_BRANCH’]
what you cannot do is “Create” a new environment or parameter value inside your build-flow and access that outside in a real post-build step.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/eb6e8b8a-aaad-4e3a-90c0-75b32eae19f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.