Jenkins 脚本管道是否支持用户输入?

zan*_*man 0 jenkins jenkins-pipeline

我想用这个input步骤提示用户输入字符串,我在我的Jenkinsfile中使用了脚本管道,即顶层块是node而不是pipeline,但是当我把这input一步放在stage块中时,蓝海只是报告失败而不是提示我输入。

input步骤是否仅支持声明性而不是脚本化?

代码如下:

node {
  input {
    message "Should we continue?"
    ok "Yes, we should."
    parameters {
      string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?')
    }
  }
  echo "Hello, ${PERSON}"
}
Run Code Online (Sandbox Code Playgroud)

Ste*_*ing 6

Yes, the input step is absolutely supported in scripted pipelines, as this is really a step and not a construct of a declarative pipeline.

EDIT after OP posted the code:

You are trying to use the declarative syntax (input { .. }) within a scripted pipeline. Correct would be:

input(message: "Should we continue?")
Run Code Online (Sandbox Code Playgroud)

You find the documentation for the input step here.