Parameters
Parameters are defined at the pipeline level, and can be used to parameterize a pipeline's configuration. These are very useful if you have to repeat a meaningful piece of text in several parts of the configuration. For example, say you define a parameter called VERSION with a value 12.1. This can be used anywhere in the pipeline's configuration to substitute the text "12.1".
<pipeline name="DeployPipeline">
<params>
<param name="VERSION">12.1</param>
</params>
<materials>
<git url="http://url.com" branch="branch-#{VERSION}" />
</materials>
<stage name="deploy">
<jobs>
<job name="deploy_win">
<tasks>
<exec command="deploy.bat" args="#{VERSION}"/>
</tasks>
</job>
<job name="deploy_linux">
<tasks>
<exec command="deploy.sh" args="#{VERSION}"/>
</tasks>
</job>
</jobs>
</stage>
</pipeline>
One of the best and most important use of parameters is within pipeline templates. Some parts of a pipeline template can be parameterized, so that each pipeline using the template can give the parameters any desired value.
An example of templates and other related documentation can be found here:
https://docs.gocd.io/current/configuration/admin_use_parameters_in_configuration.html
Environment Variables
By definition, Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. They are part of the operating environment in which a process runs.
For all practical purposes, the meaning of environment variables in GO is exactly the same as above.
Environment variables can be defined in Go at four different levels: environment level, pipeline level, stage level and job level. The lower level inherits all variables from the higher levels, and if the same variable is defined at the lower level, it overrides the one at the higher level.
When the Go server assigns a job to an agent, it gives it a list of all the relevant environment variables as well. When the job is executed on the agent, these environment variables are set and the agent process and/or any tasks run by the agent can make use of these env variables in the same way as any other system environment variables.
Go also sets some default environment variables during every job run which can be used to get information about the pipeline, during run time. For example, GO_PIPELINE_NAME, GO_PIPELINE_COUNTER etc.
More documentation can be found here :
https://docs.gocd.io/current/faq/environment_variables.html
Comments
7 comments
Is there any option to set a parameter from Environment Variable?
How should we decide when to use a Parameter vs a Variable?
Good question before be. But also there is no good instructions on how use secret parameters in materials. And also why I cannot use my pipeline environment on lower levels??
Just came across the blog, can we make the material as variable and pass the value as parameter from post commit hook ?
hi,
Ho can we pass values from one pipeline to another pipeline. For example
i notify the build pipeline so that it knows where to run its mvn command from.
How to pass desired value in parameter through GO CD UI ,I am not able to find any option in trigger with box ..
Rajesh's comment came in as a ticket. Posting it here on his behalf.
@neeraj,
I have used parameters in child that can have the parent detail and in material as #(parent) and type pipeline so that child gets triggered after parent.
May be Please explain in detail to assist you, a scenario will help too.
---------
Please note that the Go community has moved. This forum is available only for reference. Please redirect your queries to the GoCD Users Google group
Please sign in to leave a comment.