【问题标题】:Jenkins pipeline to build imageJenkins 管道构建镜像
【发布时间】:2019-12-21 02:57:37
【问题描述】:

我正在编写一个 Jenkins 管道 groovy 脚本来构建映像。我想构建一个映像并使用这个 Jenkins 管道在 EC2 中运行一些 docker 命令。 我在管道下面写了

 pipeline {
   agent none
   stages {
     stage ('image-build')
       steps{
         withAWS(region: 'us-east-1', roleAccount: 9441982XX , role: 
                'Jenkins')
         {
           sh """
             mkdir jenkins
             ls -a

            """
   }
   }      
  }
  }

但我遇到了错误

 WorkflowScript: 4: Expected a stage @ line 4, column 5.
   stage ('image-build')
   ^

 WorkflowScript: 5: Expected a stage @ line 5, column 8.
      steps{
      ^

 WorkflowScript: 3: No stages specified @ line 3, column 5.
   stages {
   ^

  3 errors

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
a

【问题讨论】:

  • 夜是语法错误。将步骤部分放入 {}。 Stage ('image-build'){ steps ....}
  • 仅供将来参考,这是一个声明性管道,而不是脚本化管道,因此除非您在声明性管道中使用脚本块,否则几乎不会涉及任何 groovy。

标签: amazon-web-services docker jenkins amazon-ec2


【解决方案1】:

stage('image-build') 放大括号 {

后出现语法错误
    pipeline {
 agent none
 stages {
  stage('image-build') {
   steps {
    withAWS(region: 'us-east-1', roleAccount: 9441982 XX, role:
     'Jenkins') {
     sh ""
     "
     mkdir jenkins
     ls - a

     ""
     "
    }
   }
  }
 }
}

【讨论】:

    猜你喜欢
    • 2018-06-15
    • 2017-07-16
    • 2018-06-19
    • 2018-01-07
    • 1970-01-01
    • 1970-01-01
    • 2018-05-14
    • 1970-01-01
    • 2019-11-15
    相关资源
    最近更新 更多