Jenkins trigger parameter plugin - file parameters

I have Project A and downstream Project B, which takes in a file parameter. Project B is triggered (from Parameterized Trigger Plugin) by A when A is completed. Is there a way that I can predefine the file parameter (e.g. file properties file) so when project A->B, B will be able to obtain the file without needing a manual selection?

Answers


You can use the Multijob plugin for this.

A simple implementation for your example would be to have a third (multijob) project which then has two multijob phases with you one project in each one. You can specify the behaviour on the exit code for each phase and use parameters with the 'advanced' button on the configuration page


EDIT The multijob plugin does not support File parameters (such as a file passed in from the browser), which is a shame

However you can fake it by

PROJECT A (__upstream)

where params.txt is the file parameter

PROJECT B (__downstream)

where params.txt is the file parameter

Results when triggered from A

Started by upstream project "__upstream" build number 8
originally caused by:
 Started by user anonymous
[EnvInject] - Loading node environment variables.
Building on master in workspace /var/lib/jenkins/workspace/__downstream
[__downstream] $ /bin/sh -xe /tmp/hudson4094819031189787422.sh
+ touch params.txt
[EnvInject] - Injecting environment variables from a build step.
[EnvInject] - Injecting as environment variables the properties file path 'params.txt'
[EnvInject] - Variables injected successfully.
[__downstream] $ /bin/sh -xe /tmp/hudson1756581135746292166.sh
+ cat params.txt
+ env
+ grep TEST
+ sort
TEST1=abc
TEST3=xyz
+ rm params.txt
Finished: SUCCESS

Results when triggered directly

Started by user anonymous
[EnvInject] - Loading node environment variables.
Building on master in workspace /var/lib/jenkins/workspace/__downstream
Copying file to params.txt
[__downstream] $ /bin/sh -xe /tmp/hudson5504289990867483427.sh
+ touch params.txt
[EnvInject] - Injecting environment variables from a build step.
[EnvInject] - Injecting as environment variables the properties file path 'params.txt'
[EnvInject] - Variables injected successfully.
[__downstream] $ /bin/sh -xe /tmp/hudson8534892071758952425.sh
+ cat params.txt
TEST1=abc
TEST3=xyz

+ env
+ sort
+ grep TEST
TEST1=abc
TEST3=xyz
+ rm params.txt
Finished: SUCCESS

You have to touch the file in the downstream, or else the EnvInject plugin chokes on no file and remember to remove the file (or rename) so the next run doesn't reuse the values


Need Your Help

Edit docx using nokogiri and rubyzip

ruby zip nokogiri replace document-management

Here, I'm using a rubyzip and nokogiri to modify a .docx file.

Linking directly to a SWF, what are the downsides?

flex flash embed

Usually Flash and Flex applications are embedded on in HTML using either a combination of object and embed tags, or more commonly using JavaScript. However, if you link directly to a SWF file it will