背景
我想确保推送分支上的所有提交消息都有时间日志
即 . add readme /spend 5m
问题
我想在bitbucket管道中获取两个git分支之间的提交差异,
这是我的yaml管道配置:
pipelines:
default:
- step:
script:
- git log $BITBUCKET_BRANCH --oneline --not master
$ BITBUCKET_BRANCH是管道正在运行的分支 .
但是在尝试与master进行比较时,管道返回错误
+ git log $BITBUCKET_BRANCH --oneline --not master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
请注意管道中的设置步骤(这是由bitbucket预先定义的,我无法更改它)
git clone --branch="abdullah-s/bitbucketpipelinesyml-created-online-wit-1489917130851" --depth 50 https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/abdullah-s/webook.git $BUILD_DIR;
git reset --hard ac61f080a28428bdd885735374164577a2b0aa43;
git remote set-url origin git@bitbucket.org:abdullah-s/webook.git
在设置的第一个命令中,bitbucket只从我的repo克隆一个分支
我尝试了什么
我试图拉大师
- git checkout -b master
- git pull origin master
- git log $BITBUCKET_BRANCH --oneline --not master
但是得到了一个错误
+ git pull origin master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
2 回答
正如您正确指出的那样,Bitbucket管道只会克隆触发构建的特定分支 .
因此,RefSpec将被设置为特定分支,并且您将无法合并或区分其他分支 .
例如,如果在开发分支上触发了构建,则将设置以下refspec:
如果你查看可用的分支,你会看到:
您可以执行以下命令:
拉入所有其他分支/标签
我没有完整的答案,只是提示:您可以通过将密码存储为SECRET环境变量来绕过权限问题,然后在拉动时将管道识别为您自己 .
https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html