在Jenkins管道中使用aws s3 cp命令时权限被拒绝

时间:2019-03-29 14:30:24

标签: amazon-s3 jenkins-plugins

我正在尝试在Jenkins管道外壳脚本步骤中将文件上传到aws s3存储桶。

我在aws ec2实例上运行Jenkins。我在Jenkins插件配置中配置了s3访问密钥和秘密密钥。我尝试使用aws s3 cp命令,s3upload和s3 sync。我可以从linux shell终端成功运行命令。

以下是我到目前为止尝试过的命令:

/root/.local/bin/aws s3 cp some-document_*.html s3://mybucket/staging/document-folder/ --include "some-document*.html"

/root/.local/bin/aws s3Upload acl: 'Private', bucket: 'mybucket', cacheControl: '', excludePathPattern: '', file: 'some-document*.html', includePathPattern: 'some-document*.html', metadatas: [''], path: 'staging/document-folder/', sseAlgorithm: '', workingDir: '$WORKSPACE/docs/markdown/'```

/root/.local/bin/aws s3 sync . s3://mybucket/staging/document-folder/ --include "some-document*.html"

当我从命令行运行这些命令时,可以在aws管理控制台上的mybucket中看到某些文档。当我运行Jenkins管道时,我得到

[2019-03-27T18:25:08.052Z] + /root/.local/bin/aws s3 cp some-document.html s3://mybucket/staging/document-folder --include 'some-document*.html' --profile jenkins

[2019-03-27T18:25:08.052Z] /var/lib/jenkins/workspace/project_folder@tmp/durable-60152ab5/script.sh: line 5: /root/.local/bin/aws: Permission denied

script returned exit code 1

1 个答案:

答案 0 :(得分:0)

与Steven Deal @ Cloudbees一起工作,我们发现我指出了aws命令的错误路径。正确的命令是/ usr / local / bin / aws s3 cp文件名s3:// mybucket / path / dir --include filename * .html