【问题标题】:Permission denied while using aws s3 cp command in a Jenkins pipeline在 Jenkins 管道中使用 aws s3 cp 命令时权限被拒绝
【发布时间】:2019-03-29 14:30:23
【问题描述】:

我正在尝试在 Jenkins 管道 shell 脚本步骤中将文件上传到 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

【问题讨论】:

  • 我认为jenkins运行命令的系统用户没有运行命令的权限。类似使用sudo 执行此命令。

标签: amazon-s3 jenkins-plugins


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-11
    • 2021-11-02
    • 2023-01-26
    • 2011-05-13
    • 2020-03-23
    • 2016-01-20
    • 1970-01-01
    相关资源
    最近更新 更多