In Jenkins’s declarative pipeline, you can add parameters as part of Jenkinsfile. There are many supported parameters type that you can use with a declarative pipeline.

In this blog, you have answers to the following.

  1. How to use parameters in the declarative pipeline?
  2. How to use dynamic parameters or active choice parameters in the declarative pipeline?

Generating Pipeline Code for Parameters

You can generate the parameter pipeline code block easily using the Jenkins pipeline generator. You will find the Pipeline syntax generator link under all the pipeline jobs, as shown in the image below.

Jenkins pipeline syntax generator

Navigate to the pipeline generator in Jenkins and under steps, search for properties, as shown below.

Generating Jenkins parameter code for declarative pipeline

Using Parameters in Jenkinsfile

Here is an example ready to use Jenkins declarative pipeline with parameters.

This script has the following parameter types.

  1. Choice parameters
  2. Boolean parameter
  3. Multi-line string parameter
  4. String Parameter

Here is the Github link for this code.

pipeline {
   ...



UCSD DevOps CICD

Continue reading on source link