TECHIES WORLD

For Techs.... Techniques.... Technologies....

BashLinux

How to accept user input in Jenkins pipeline

Its possible to prompt an interactive input from user in Jenkins pipeline during build.

We can use the following sample groovy snippet for prompting user input.

pipeline {
    agent any
    stages {
        stage ("Prompt for input") {
            steps {
                script {
                    env.INPUT = input message: 'Please enter the input',
                         parameters: [string(defaultValue: '',
                                      description: '',
                                      name: 'Input')]
            }
            echo "Input: ${env.INPUT}"
            }
        }
    }
}

This will ask for the user input and print the same during build.

That's all…