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



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

我正在 aws ec2 实例上运行 Jenkins。我在 Jenkins 插件配置中配置了 s3 访问密钥和私有密钥。 我尝试使用 aws s3 cp 命令、s3upload 和 s3 同步。 我可以成功地从 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

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

最新更新