Jenkins Tutorial – Part 7 – Interactive Pipelines
In this part of the Jenkins tutorial, I will discuss a pipeline input
directive used to prompt input during job execution. The input directive will cause the build process to pause and wait for direct human interactions. We usually use this option for the CD pipelines. If you didn’t read the previous articles, I suggest you read them first.
Follow our social media:
https://www.linkedin.com/in/ssbostan
https://www.linkedin.com/company/kubedemy
https://www.youtube.com/@kubedemy
Why and When to Use the Input Directive:
As I said, the input directive will cause the job to pause and wait for direct human interactions. So why do we need that? In some cases, usually in continuous delivery pipelines, we want to double-check everything before letting them deploy to our production environments. In such a situation, the input directive is what we need. Another use of the input directive is to get user values during the build process.
Pausing the build process will cause the Jenkins job executor to be busy until resuming it! You should not use the input directive if you have a limited number of job executors and many jobs with the input directive. In future articles, I will explain the Jenkins cloud agents to deploy dynamic agents to let us get around this limitation.
In the above example, simple use of the input directive is shown. The input directive will take effect just after evaluating the options
block of the stage and before evaluating the agent
, and when
blocks of the stage.
Who can submit the input:
By default, any user can submit the input, but we can limit who can submit it by using the submitter option of the input directive.
submitter: A comma-separated list of users or groups allowed to submit this input.
submitterParameter: If the submitter option is set, this option can be used to set the submitter username in the pipeline’s environment variable
Input in combination with Parameters:
As said, another use of the input directive is to get user values during the build process. By using the parameters option in the input block, we can ask the user to submit values.
For getting more hands-on parameters, see this article.
Here is an example screenshot:
Input within the Pipeline steps:
The input
method can be used within the pipeline steps to pause the build and wait for the user to enter values. The key difference between the input method and the input directive is the input method gets executed after the options
, agent
, and when
blocks while the input directive gets executed before agent
and when
blocks.
Final words:
The input directive is helpful for the Jenkins environments using cloud agents introduced in future articles. With the power of the input directive, you can pause the build process for human interaction or use them to enter values during the build.
You can find all tutorial materials in the following GitHub repository:
https://github.com/ssbostan/jenkins-tutorial
If you like this series of articles, please share them and write your thoughts as comments here. Your feedback encourages me to complete this massively planned program.
Follow my LinkedIn https://www.linkedin.com/in/ssbostan
Follow Kubedemy LinkedIn https://www.linkedin.com/company/kubedemy
Follow Kubedemy Telegram https://telegram.me/kubedemy