在向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用户编写的权限,但是我无法这样做,用户名没有出现:

在存在分支保护的情况下,是否有一种允许该用户提交的方法,或者是否有可能给予该用户写入的权限?
提前谢谢。
发布于 2021-03-25 19:24:44
您需要创建一个"bot“用户,然后单击其化身,选择一个工作区,然后单击Settings > 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/
https://stackoverflow.com/questions/64484354
复制相似问题