In a Jenkins pipeline, I want to provide an option to the user to give an interactive input at run time. I want to understand how we can read the user input in the Groovy script.
I'm referring to this documentation.
After some trials I've got this working:
pipeline {
agent any
stages {
stage("Interactive_Input") {
steps {
script {
def userInput = input(
id: 'userInput', message: 'Enter path of test reports:?',
parameters: [
[$class: 'TextParameterDefinition', defaultValue: 'None', description: 'Path of config file', name: 'Config'],
[$class: 'TextParameterDefinition', defaultValue: 'None', description: 'Test Info file', name: 'Test']
])
echo ("IQA Sheet Path: "+userInput['Config'])
echo ("Test Info file path: "+userInput['Test'])
}
}
}
}
}
In this example I'm able to echo (print) the user input parameters:
echo ("IQA Sheet Path: "+userInput['Config'])
echo ("Test Info file path: "+userInput['Test'])
but I'm not able to write these parameters to a file or assign them to a variable. How can we achieve this?