User input in declarative pipeline

673 views
Skip to first unread message

Bert

unread,
Mar 2, 2017, 1:34:06 AM3/2/17
to Jenkins Users
Hello everyone,

One of the CloudBees support articles describes how to do a user input in a pipeline script, as alternative for the promoted builds plug-in. I'm trying to do that, but then with a declarative pipeline definition.

I know that's possible through a script block inside the pipeline definition, but I'd like to prevent that and stay in the declarative model.

Is that possible?

Thanks in advance,
Bert

Bill Dennis

unread,
Mar 2, 2017, 3:15:46 AM3/2/17
to Jenkins Users
I've seen it used in a 'when' condition - in this example online: https://github.com/sta-szek/pojo-tester/blob/master/Jenkinsfile

Here is an extract from that:
when {
    expression
{
       
boolean publish = false
        if (env.DEPLOYPAGES == "true") {
           
return true
        }
       
try {
            timeout
(time: 1, unit: 'MINUTES') {
                input
'Deploy pages?'
                publish = true
            }
       
} catch (final ignore) {
            publish
= false
        }
       
return publish
   
}
}

But is doesn't seem to usable as a 'first class' step in a steps section without dropping into script.

Bill
Reply all
Reply to author
Forward
0 new messages