Thanks!
What worked for me was
println bParent.build.properties.environment['GIT_TREE']
The issue I had was due to the quotes and how I was using them.
Thanks for your help!
On Thursday, February 19, 2015 at 10:53:47 AM UTC-5, rginga wrote:
> 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:* [email protected] <javascript:> [mailto:
> [email protected] <javascript:>] *On Behalf Of *Katie Outram
> *Sent:* Thursday, February 19, 2015 10:43 AM
> *To:* [email protected] <javascript:>
> *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 [email protected] <javascript:>.
> 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/3419094b-1158-40ad-9500-19a6c83c2500%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.