gpt4 book ai didi

git - 如何仅向 bitbucket 中的 bitbucket-pipelines 用户授予写权限

转载 作者:行者123 更新时间:2023-12-05 04:57:19 25 4
gpt4 key购买 nike

develop 分支添加分支保护之前,bitbucket-pipelines 用户在发布结束时自动将版本更改提交到 develop 分支。

添加分支保护后,发布失败,因为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 用户写权限,但是我做不到,用户名没有出现:

Can't find user.

有没有办法允许这个用户即使有分支保护也可以提交,或者是否可以给这个用户写权限?

提前致谢。

最佳答案

您需要创建一个“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/

关于git - 如何仅向 bitbucket 中的 bitbucket-pipelines 用户授予写权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64484354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com