Go allows you to parameterize your pipelines and pipeline templates. This powerful feature can help reduce repetition within your configurations and also allows for complex setups using a combination of parameters and pipeline templates.
Edit the Parameters tab when defining a pipeline .
Parameter values are defined in the < params > tag within a pipeline and can be used anywhere within that pipeline using #{param_name}. The following example defines a new parameter called "myParam" and uses it in a job.
<pipeline name="my_pipeline">
<params>
<param name="myParam">hello world</param>
</params>
<stage name="my_stage">
<jobs>
<job name="my_job">
<tasks>
<exec command="echo" args="#{myParam}"/>
</tasks>
</job>
</jobs>
</stage>
</pipeline>
NOTE: If you want to use the # literal, you can escape it using another # literal. For example, if the parameter "foo" has the value "one", then:
String | Evaluates to |
---|---|
#{foo} | one |
##{foo} | #{foo} |
###{foo} | #one |
Parameter usage within templates is similar to usage within pipelines. The only difference being, you cannot define parameters in a template.
<pipeline name="trunk" template="my_template">
<params>
<param name="WORKING_DIR">trunk</param>
</params>
...
</pipeline>
<pipeline name="branch" template="my_template">
<params>
<param name="WORKING_DIR">branch</param>
</params>
...
</pipeline>
The parameter defined above is used the template below.
<pipeline name="my_template">
<stage name="my_stage">
<jobs>
<job name="my_job">
<tasks>
<exec command="echo" args="Updating code from svn repository svn://codebase/#{WORKING_DIR}"/>
</tasks>
</job>
</jobs>
</stage>
</pipeline>
While parameters are generally very flexible, there are some restrictions.
You cannot use a parameter to define:
Other restrictions: