问题描述
我在Gitlab的ci中使用https://github.com/researchgate/gradle-release
和以下配置:
release:
image: gradle:jdk11
stage: release
script:
- git checkout master
- ./gradlew release
only:
- master
when: manual
它抱怨用户无权写入存储库。
Execution Failed for task ':example-core:preTagCommit'.
> Failed to push to remote - [][remote: You are not allowed to upload code.
fatal: unable to access 'https://gitlab.com/myUser/example.git/': The
requested URL returned error: 403
我检查了一下,CI作业令牌只有读取权限。有没有一种方法可以理想地使用令牌而不是硬编码凭据在此处作为脚本的一部分登录?谢谢。
编辑一个: 我尝试通过以下配置使用SSH密钥/部署密钥。但这不起作用:
release:
image: gradle:jdk11
stage: release
script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -
y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$CI_CD_SSH_KEY")
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- git config --global user.email "[email protected]"
- git config --global user.name "GitLab CI/CD"
- git checkout -B master
- ./gradlew release -DskipTests
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)