You are currently viewing Jenkins pipeline part 6 – parameters

Jenkins pipeline part 6 – parameters

Jenkins pipeline part 6 – parameters

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In today’s blog post, we will discuss parameters in a Jenkins pipeline and how to pass arguments in Jenkins pipeline using parameter directive.

What is parameters is Jenkins pipeline?

The parameters directive provides a list of parameters that a user can provide when triggering the Pipeline. The values for these user-specified parameters are made available to Pipeline steps via the params object.

Let’s dig down a bit with some examples.

Jenkins pipeline part 6 – parameters

Prerequisites

One system with Jenkins installed.

string:

Pass a string value to your Jenkins pipeline using string parameters.

Create a new pipeline in your Jenkins controller server using below Jenkinsfile definition. Replace the label as per your Jenkins configuration.

Trigger the pipeline depending on you pipeline setup.

Jenkins pipeline part 6 – parameters

Jenkins pipeline part 6 – parameters

text:

Pass a multiline string value to your Jenkins pipeline using text parameters.

Update the pipeline definition with below and rerun the pipeline.

Jenkins will ask you to supply parameters values. Provide a multiline parameter and execute.

Jenkins pipeline part 6 – parameters

Jenkins pipeline part 6 – parameters

Jenkins pipeline part 6 – parameters

booleanParam

Pass a Boolean value (true or false) to your Jenkins pipeline using booleanParam parameters.

Update the pipeline definition with below and rerun the pipeline.

Jenkins will ask to confirm parameters values. Check or uncheck the parameter and click “Build”.

Jenkins pipeline part 6 – parameters

Jenkins pipeline part 6 – parameters

Jenkins pipeline part 6 – parameters

choice:

Pass a list of values to your Jenkins pipeline using choice parameters.

Update the pipeline definition with below and rerun the pipeline.

Jenkins will ask to confirm parameters values. Select the parameter value from dropdown and click “Build”.

Jenkins pipeline part 6 – parameters

Jenkins pipeline part 6 – parameters

Jenkins pipeline part 6 – parameters

password:

Pass a secret value (password) to your Jenkins pipeline using choice password.

Update the pipeline definition with below and rerun the pipeline.

Jenkins will ask to confirm parameters values. Click on “Build” to use the default password or “Change Password” to update the password and then click “Build”.

Jenkins pipeline part 6 – parameters

Jenkins pipeline part 6 – parameters

Jenkins pipeline part 6 – parameters

Hope you have enjoyed this article, to get more details on Jenkins, please refer below Jenkins official documentation.

https://www.jenkins.io/doc/

Leave a Reply