Hi,

trying to get started with pipelines and am having difficulties combining 
"input" and "stage" steps.

Starting from this Cloudbees KB example 
<https://go.cloudbees.com/docs/support-kb-articles/CloudBees-Jenkins-Enterprise/Pipeline---How-to-add-an-input-step,-with-timeout,-that-continues-if-timeout-is-reached,-using-a-default-value.html>,
 
if I just use it as-is, then it works.

If I wrap a stage around the output node, it still works as intended but 
the UI is a little cludgy as I need to go to the build's dropdown menu to 
provide the input.

The user interface becomes much nicer if I also wrap the input in a 
separate stage so it shows up in the Stage View, but then the output stage 
breaks. It looks like the information is lost between stages, can this 
somehow be circumvented?

If I run this pipeline (no, the default values are not real ones):

stage('input') {
    def userInput = input(
        id: 'userInput', message: 'AWS Credentials?', parameters: [
            [$class: 'TextParameterDefinition', defaultValue: 
'ASIAILTN6HUOSJUT5NRA', description: 'AWS Access Key ID', name: 
'AWS_ACCESS_KEY_ID'],
            [$class: 'TextParameterDefinition', defaultValue: 
'z4aiU9IALIahLhY0nX2tzzj2RO6DvObWD0LDf6V9', description: 'AWS Secret Access 
Key', name: 'AWS_SECRET_ACCESS_KEY']
    ]) 
}

stage('output') {
    node {
        sh 'export'
        echo ("AWS Acess Key ID: "+userInput['AWS_ACCESS_KEY_ID'])
        echo ("AWS Secret Access Key: "+userInput['AWS_SECRET_ACCESS_KEY'])
    }
}

then the output fails, and the console output contains this:

export USER="jenkins"
export WORKSPACE="/var/lib/jenkins/workspace/test"
export XFILESEARCHPATH="/usr/dt/app-defaults/%L/Dt"
export 
_="/var/lib/jenkins/workspace/test@tmp/durable-5928a78d/script.sh"[Pipeline] 
}[Pipeline] // node[Pipeline] }[Pipeline] // stage[Pipeline] End of 
Pipelinegroovy.lang.MissingPropertyException: No such property: userInput for 
class: groovy.lang.Binding
        at groovy.lang.Binding.getVariable(Binding.java:63)
        at 
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:224)
        at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
        at 
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
        at 
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
        at 
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
        at 
com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28)
        at 
com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)


with kind regards,

  Bent Terp

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/62908157-158d-4033-87bd-c5bace9c1bd2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to