我的目标是在由其他存储库触发后,使用.gitlab-ci.yaml文件进行自动提交。
我能够成功登场并提交更改。
最后一步是执行 git push ,它会一直失败并显示403错误代码:
我的脚本:
default:
before_script:
- mkdir ~/.ssh
- echo $GITLAB_DEPLOY_KEY > id_rsa
- mv id_rsa ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan -H $CI_SERVER_HOST >> ~/.ssh/known_hosts
- git config --global user.email $GITLAB_USER_EMAIL
- git config --global user.name $GITLAB_USER_NAME
update_repo:
script:
- git add filename.txt
- git commit -m 'Updated filename.txt'
- git push origin HEAD:${UPSTREAM_BRANCH}
错误堆栈:
remote: You are not allowed to upload code.
fatal: unable to access 'https://gitlab-ci-token:[MASKED]@gitlab.ad.xxxxxxxxx.us/abc/xyz.git/': The requested URL returned error: 403
我还尝试将远程URL设置为SSH,并尝试通过SSH执行git push
。但是跑步者因其他错误坠毁。所以我从脚本中删除了以下行
- git remote set-url origin git@gitlab.ad.xxxxxxxxx.us:abc/xyz.git