简体   繁体   中英

Jenkins pipeline to build image

I am writing a Jenkins pipeline groovy script to build image.I want to build one image and run some docker commands inside EC2 using this Jenkins pipeline. I have written below pipeline

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

            """
   }
   }      
  }
  }

But i am getting below errors

 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

Its a syntax error after stage('image-build') put curly brace {

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

     ""
     "
    }
   }
  }
 }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM