在Jenkins中未找到带有“的sshCommand”;ssh管道步骤“;安装

在Jenkins中未找到带有“的sshCommand”;ssh管道步骤“;安装,jenkins,ssh,jenkins-pipeline,jenkins-declarative-pipeline,Jenkins,Ssh,Jenkins Pipeline,Jenkins Declarative Pipeline,我尝试在我的Jenkins文件中使用sshCommand,并且已经安装了“SSH管道步骤”插件, 但是Jenkins的构建错误是: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 60: Unknown stage section "sshCommand". Starting with version 0.5, steps in a

我尝试在我的Jenkins文件中使用sshCommand,并且已经安装了“SSH管道步骤”插件, 但是Jenkins的构建错误是:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 60: Unknown stage section "sshCommand". Starting with version 0.5, steps in a stage must be in a ‘steps’ block. @ line 60, column 5.
       stage('Remote SSH') {
       ^

WorkflowScript: 60: Multiple occurrences of the sshCommand section @ line 60, column 5.
       stage('Remote SSH') {
       ^

WorkflowScript: 60: Unknown stage section "sshCommand". Starting with version 0.5, steps in a stage must be in a ‘steps’ block. @ line 60, column 5.
       stage('Remote SSH') {
       ^

WorkflowScript: 60: Expected one of "steps", "stages", or "parallel" for stage "Remote SSH" @ line 60, column 5.
       stage('Remote SSH') {
       ^

4 errors
这是我的文件:

def remote = [name: "${host}", host: "${host}", user: "root", allowAnyHosts: true]
stage('Remote SSH') {
      sshCommand remote: remote, command: "npm install"
      sshCommand remote: remote, command: "npm run start"
}
在这里,它已经安装好了:


如果要使用Jenkins Pipeline插件的接口,则插件公开的函数或方法必须包含在
步骤
块中:

stage('Remote SSH') {
  steps {
    sshCommand remote: remote, command: "npm install"
    sshCommand remote: remote, command: "npm run start"
  }
}

您显示的错误将被修复。

谢谢,是的,在我使用舞台内部的步骤后,它会工作