Reputation: 209
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
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
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
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
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