Shashank
Shashank

Reputation: 209

jenkins pipeline s3 file download

I am trying to add a step in jenkins to download from s3

//download file from s3
withAWS(credentials:'credss') { 
  s3Download(file:'test.json', bucket:'test', path:'/devops/test.json',force:true)
}

I am getting this below error

java.lang.NoSuchMethodError: No such DSL method 'withAWS' found among steps

Upvotes: 3

Views: 21399

Answers (5)

Satyam Pandey
Satyam Pandey

Reputation: 743

Any one have to stage to uplod jenkins logs to s3bucket

Upvotes: 0

Munugala Vijay
Munugala Vijay

Reputation: 11

pipeline {
  agent any
  stages {
    stage('download') {
        steps {
    withAWS(credentials:'XXXX',region:'XXXXXX') {
          s3Download bucket:'bucketname',file:'toPath', path:'fromPath',force:true
        }
      }
    }
    stage('Done') {
      steps {
        echo "done"
      }
    }
  }
}

Upvotes: 1

Shashank
Shashank

Reputation: 209

    //download file from s3 
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'credentails']]) {
echo "copying file from s3"
sh "aws s3 cp --quiet s3://bucketname/example.json example.json"
}

I also downloaded the plugin AWS Steps.

Upvotes: 0

Rajesh Ayaldasani
Rajesh Ayaldasani

Reputation: 141

First: download a plugin AWS Steps

Second: Store your credentials in Jenkins

Third: Write this pipeline

pipeline 
{
agent any
    stages
    {
      stage('S3download') 
        {      
            steps {
                withAWS(region:'XXXXX',credentials:'ID of aws credentials')\
                {
                    s3Download(file: 'filename', bucket: 'bucket name', path: '')
                }
            }
        }
    }
}

Upvotes: 0

pavan
pavan

Reputation: 71

make sure the pipeline: AWS Steps plugin is installed. Add your user AWS credentials to the Jenkins. Make sure the user has the permissions to download the file from S3. Please refer Pipeline: AWS Steps Github for additional syntax's how to integrate AWS services with jenkins pipeline.

pipeline {
agent any
stages {
    stage('S3download') {
      steps {
    withAWS(credentials:'awscredentials') {
        s3Download(file: 'key', bucket: 'test', path: '/home/ubuntu/')
      }
    }
    }
}
}

Upvotes: 7

Related Questions