首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何只对bitbucket中的bitbucket-管道用户授予写权限

如何只对bitbucket中的bitbucket-管道用户授予写权限
EN

Stack Overflow用户
提问于 2020-10-22 14:24:13
回答 1查看 2.3K关注 0票数 3

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

添加分支保护后,由于bitbucket-pipelines没有写入分支的权限,因此发布失败。以下是错误:

代码语言:javascript
复制
+ 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文件:

代码语言:javascript
复制
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用户编写的权限,但是我无法这样做,用户名没有出现:

在存在分支保护的情况下,是否有一种允许该用户提交的方法,或者是否有可能给予该用户写入的权限?

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-03-25 19:24:44

您需要创建一个"bot“用户,然后单击其化身,选择一个工作区,然后单击Settings > OAuth使用者>添加使用者,然后在管道配置中使用客户端ID和机密:

代码语言:javascript
复制
# 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/

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64484354

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档