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.

From: jenkinsci-users@googlegroups.com 
[mailto:jenkinsci-users@googlegroups.com] On Behalf Of Katie Outram
Sent: Thursday, February 19, 2015 10:43 AM
To: jenkinsci-users@googlegroups.com
Subject: Build Flow Plugin questions on how to access defined values

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
bParent = build ("build_start",
                              TOOL_BRANCH : params['TOOL_BRANCH'],
                              TOOL_CHANGE_NUMBER : params['TOOL_CHANGE_NUMBER']
  )
if (bParent.build.properties.environment['TOOL_CHANGE_MERGED'] == 'TRUE') {
    return 0
}
parallel (
        {build ("update_issue", EnvVarFile : 
bParent.build.properties.environment['ENV_VAR_FILE']) },
        {build ("verify_commit_message", EnvVarFile : 
bParent.build.properties.environment['ENV_VAR_FILE']) }
)
My ultimate goal is to clean up after the steps listed above (rm -rf several 
directories but keep certain directories).   I have tried breaking this down to 
just println a value from Jenkins, and everytime I do this, my script fails.
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<http://stacktrace.jenkins-ci.org/search?query=groovy.lang.MissingPropertyException>:
 No such property: TOOL_BRANCH for class: Script1
        at 
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)<http://stacktrace.jenkins-ci.org/search/?query=org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap&entity=method>
        at 
org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)<http://stacktrace.jenkins-ci.org/search/?query=org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty&entity=method>
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)<http://stacktrace.jenkins-ci.org/search/?query=org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty&entity=method>
        at 
Script1.run(Script1.groovy:42)<http://stacktrace.jenkins-ci.org/search/?query=Script1.run&entity=method>
        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)
        at hudson.model.OneOffExecutor.run(OneOffExecutor.java:66)

--
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-users+unsubscr...@googlegroups.com<mailto:jenkinsci-users+unsubscr...@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<https://groups.google.com/d/msgid/jenkinsci-users/eb6e8b8a-aaad-4e3a-90c0-75b32eae19f7%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/6C6EE445A6F6CE4E8A0FFB51B071A4E26E4FCC48%40AMERMBX02.PERKINELMER.NET.
For more options, visit https://groups.google.com/d/optout.

Reply via email to