Skip to main content
added 289 characters in body
Source Link
Sourav
  • 3.5k
  • 3
  • 16
  • 31

Let’s take the example of String parameter.

Below pipeline snippet will help you to include the Straing parameter in jenkinsfile.

 properties([ parameters([ string(name: 'DEPLOY_ENV', defaultValue: 'TESTING', description: 'The target environment') ]) ]) 

So, your jenkinsfile will be like:

properties([ parameters([ string(name: 'DEPLOY_ENV', defaultValue: 'TESTING', description: 'The target environment', ) ]) ]) pipeline { agent any stages { stage ("Example") { steps { script{ echo "Hello World" echo "${params.DEPLOY_ENV}" } } } } } 

Edit:

Using the below command, I triggered the jenkins job.

curl -vvv -u "xxx:xxxx" -X POST "http://xx.xxx.xxx.xxx:8080/job/test-param/buildWithParameters?DEPLOY_ENV=SOURAV" 

Output:

enter image description here

Let’s take the example of String parameter.

Below pipeline snippet will help you to include the Straing parameter in jenkinsfile.

 properties([ parameters([ string(name: 'DEPLOY_ENV', defaultValue: 'TESTING', description: 'The target environment') ]) ]) 

So, your jenkinsfile will be like:

properties([ parameters([ string(name: 'DEPLOY_ENV', defaultValue: 'TESTING', description: 'The target environment', ) ]) ]) pipeline { agent any stages { stage ("Example") { steps { script{ echo "Hello World" echo "${params.DEPLOY_ENV}" } } } } } 

Let’s take the example of String parameter.

Below pipeline snippet will help you to include the Straing parameter in jenkinsfile.

 properties([ parameters([ string(name: 'DEPLOY_ENV', defaultValue: 'TESTING', description: 'The target environment') ]) ]) 

So, your jenkinsfile will be like:

properties([ parameters([ string(name: 'DEPLOY_ENV', defaultValue: 'TESTING', description: 'The target environment', ) ]) ]) pipeline { agent any stages { stage ("Example") { steps { script{ echo "Hello World" echo "${params.DEPLOY_ENV}" } } } } } 

Edit:

Using the below command, I triggered the jenkins job.

curl -vvv -u "xxx:xxxx" -X POST "http://xx.xxx.xxx.xxx:8080/job/test-param/buildWithParameters?DEPLOY_ENV=SOURAV" 

Output:

enter image description here

Source Link
Sourav
  • 3.5k
  • 3
  • 16
  • 31

Let’s take the example of String parameter.

Below pipeline snippet will help you to include the Straing parameter in jenkinsfile.

 properties([ parameters([ string(name: 'DEPLOY_ENV', defaultValue: 'TESTING', description: 'The target environment') ]) ]) 

So, your jenkinsfile will be like:

properties([ parameters([ string(name: 'DEPLOY_ENV', defaultValue: 'TESTING', description: 'The target environment', ) ]) ]) pipeline { agent any stages { stage ("Example") { steps { script{ echo "Hello World" echo "${params.DEPLOY_ENV}" } } } } }