jenkins管道s3文件下载

时间:2018-07-06 15:45:53

标签: jenkins jenkins-pipeline

我正尝试在jenkins中添加一个步骤以从s3下载

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

我得到以下错误

  

java.lang.NoSuchMethodError:在步骤之间找不到这样的DSL方法“ withAWS”

3 个答案:

答案 0 :(得分:1)

确保已安装pipeline: AWS Steps插件。将您的用户AWS凭证添加到Jenkins。确保用户有权从S3下载文件。有关如何将AWS服务与jenkins管道集成的其他语法,请参阅管道:AWS步骤Github

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

答案 1 :(得分:0)

首先:下载一个插件AWS Steps

第二:将您的凭据存储在Jenkins中

第三:编写此管道

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

答案 2 :(得分:0)

    //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"
}

我还下载了插件AWS Steps。