Build Flow Plugin questions on how to access defined values

668 views
Skip to first unread message

Katie Outram

unread,
Feb 19, 2015, 10:43:10 AM2/19/15
to jenkins...@googlegroups.com

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: 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 org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)

        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)

        at hudson.model.OneOffExecutor.run(OneOffExecutor.java:66)
 

Ginga, Dick

unread,
Feb 19, 2015, 10:53:47 AM2/19/15
to jenkins...@googlegroups.com

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.

Katie Outram

unread,
Feb 24, 2015, 9:13:04 AM2/24/15
to jenkins...@googlegroups.com
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!
Reply all
Reply to author
Forward
0 new messages