[workflow-plugin] how do you access job output parameters?

280 views
Skip to first unread message

Andy Piper

unread,
Feb 4, 2015, 10:44:56 AM2/4/15
to jenkins...@googlegroups.com
In particular I have a job that uses p4 and therefore sets the variable P4_CHANGELIST which I can pass to downstream jobs. How do I access this parameter from a job in order to pass it on when using the workflow plugin?

I want something like:

def thejob = build('myjob');
build job: 'nextjob: parameters: thejob.P4_CHANGELIST

or something. I'm sure it's simple but I cannot find any documentation that gives me any clues.

Thanks

andy

Ginga, Dick

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

I don’t use the workflow plugin I use the build flow plugin, but I one way would get be like this:

 

thejob.properties["environment"]["P4_CHANGELIST"]

--
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/c73b6132-ea93-4708-a718-477355061d1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andy Piper

unread,
Feb 6, 2015, 11:32:04 AM2/6/15
to jenkins...@googlegroups.com
So to answer my own question, here is what worked for me:


    def corejob = build job: 'MyJob', parameters: buildparams
    def item = hudson.model.Hudson.instance.getItem('MyJob') 
    def changelist = item.lastBuild.getEnvironment(null).get('P4_CHANGELIST')
    buildparams.add(new hudson.model.StringParameterValue('P4_CHANGELIST',changelist));

and so on. A bit cumbersome but it appears to work. The documentation this is really poor IMO.

andy

Baptiste Mathus

unread,
Feb 7, 2015, 2:25:16 AM2/7/15
to jenkins...@googlegroups.com


Le 6 févr. 2015 17:32, "Andy Piper" <tech...@andypiper.com> a écrit :
>
> So to answer my own question, here is what worked for me:
>
>
>     def corejob = build job: 'MyJob', parameters: buildparams
>     def item = hudson.model.Hudson.instance.getItem('MyJob') 
>     def changelist = item.lastBuild.getEnvironment(null).get('P4_CHANGELIST')
>     buildparams.add(new hudson.model.StringParameterValue('P4_CHANGELIST',changelist));
>
> and so on. A bit cumbersome but it appears to work. The documentation this is really poor IMO.

Great! So maybe you could file a pull request and/or enrich wiki pages you may have found?

Thanks


>
> andy
>
> On Wednesday, 4 February 2015 15:44:56 UTC, Andy Piper wrote:
>>
>> In particular I have a job that uses p4 and therefore sets the variable P4_CHANGELIST which I can pass to downstream jobs. How do I access this parameter from a job in order to pass it on when using the workflow plugin?
>>
>> I want something like:
>>
>> def thejob = build('myjob');
>> build job: 'nextjob: parameters: thejob.P4_CHANGELIST
>>
>> or something. I'm sure it's simple but I cannot find any documentation that gives me any clues.
>>
>> Thanks
>>
>> andy
>

> --
> 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/093fffe6-57ac-4371-b91e-03d92781f9dc%40googlegroups.com.

Jesse Glick

unread,
Feb 25, 2015, 6:10:53 PM2/25/15
to jenkins...@googlegroups.com
On Wednesday, February 4, 2015 at 10:44:56 AM UTC-5, Andy Piper wrote:
I want something like:

def thejob = build('myjob');
build job: 'nextjob: parameters: thejob.P4_CHANGELIST

Reasonable but not yet supported:

Reply all
Reply to author
Forward
0 new messages