[英]How to give write permission only to bitbucket-pipelines user in bitbucket
在为开发分支添加分支保护之前, bitbucket-pipelines用户在发布结束时自动将版本更改提交到开发分支。
添加分支保护后,发布失败,因为bitbucket-pipelines没有写入分支的权限。 这是错误:
+ git push && git push --tags
remote: Permission denied to update branch develop.To http://bitbucket.org/team_name/repo_name
! [remote rejected] develop -> develop (pre-receive hook declined)
error: failed to push some refs to 'http://bitbucket.org/team_name/repo_name'
这是bitbucket-pipelines.yml文件:
pipelines:
branches:
develop:
- step:
name: test
script:
- npm install
- npm run tsc
- npm test
- step:
name: release
trigger: manual
caches:
- node
script:
- npm install
- npm run tsc
- npm publish
- npm version minor -m "Upgrade to %s [skip ci]"
- git push && git push --tags
我试图授予bitbucket-pipelines用户写入权限,但是我无法做到这一点,没有出现用户名:
即使有分支保护,有没有办法允许此用户提交,或者是否可以授予此用户写入权限?
提前致谢。
你需要创建一个“bot”用户,然后点击它的头像,选择一个工作区,点击设置 > OAuth 消费者 > 添加消费者,然后在你的管道配置中使用客户端 ID 和密码:
# Get an oauth access token using the client credentials, parsing out the token with jq.
- apt-get update && apt-get install -y curl jq
- >
export access_token=$(curl -s -X POST -u "${CLIENT_ID}:${CLIENT_SECRET}" \
https://bitbucket.org/site/oauth2/access_token \
-d grant_type=client_credentials -d scopes="repository"| jq --raw-output '.access_token')
# Configure git to use the oauth token.
- git remote set-url origin "https://x-token-auth:${access_token}@bitbucket.org/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}"
# Make changes and commit back.
- echo "Made a change in build ${BITBUCKET_BUILD_NUMBER}" >> changes.txt
- git add changes.txt
- git commit -m "[skip ci] Updating changes.txt with latest build number."
- git push
更多信息: https : //support.atlassian.com/bitbucket-cloud/docs/push-back-to-your-repository/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.