How to generate parameter code block in Jenkins?
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. Navigate to the pipeline generator in Jenkins and under steps, search for properties, as shown below.
How to limit Jenkins pipeline to specific nodes?
See https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#node-allocate-node for an extended explanation of the arguments to node. Edit 2019: This answer (and question) was made back in 2017, back then there only was one flavor of Jenkins pipeline, scripted pipeline, since then declarative pipeline has been added.
How to use parameters in Jenkins declarative pipeline?
You can access a parameter in any stage of a pipeline. Accessing parameters in stages is pretty straightforward. You just have to use params. [NAME] in places where you need to substitute the parameter.
Is there only one flavor of Jenkins pipeline?
Edit 2019: This answer (and question) was made back in 2017, back then there only was one flavor of Jenkins pipeline, scripted pipeline, since then declarative pipeline has been added. So above answer is true for scripted pipeline, for answers regarding declarative pipeline please see other answers below.
Can a groovy file be loaded from a jenkinsfile?
If your Jenkinsfile and groovy file in one repository and Jenkinsfile is loaded from SCM you have to do: You have to do checkout scm (or some other way of checkouting code from SCM) before doing load. If you have pipeline which loads more than one groovy file and those groovy files also share things among themselves:
How to dynamically fill Jenkins choice parameter with Git branches?
Currently this parameter is a string parameter. Is there any way to make this parameter a choice parameter and dynamically fill the drop down list with the Git branches? I don’t want to require someone to maintain this choice parameter by manually configuring the drop down every time a new branch is created.
How to use a branch specifier in Jenkins?
To use the branch in a build I typically name the parameter “branch” and then under “Source Code Management” (with Git selected) use “${branch}” (without the quotes) for the “Branches to build” “Branch Specifier (blank for ‘any’)” field. Hope that helps.