shell – 无法从gitlab-ci.yml推送
发布时间:2020-12-15 17:02:58 所属栏目:安全 来源:网络整理
导读:我和同事一起工作的C库每天都变得越来越重要.我们已经通过gitlab-ci.yml文件构建了持续集成实用程序,它们让我们: 构建和扩展在调试模式下测试 构建和扩展在发布模式下测试 使用Valgrind执行内存泄漏等安全检查,并检查我们的库中是否有任何我们不想要的清晰
我和同事一起工作的C库每天都变得越来越重要.我们已经通过gitlab-ci.yml文件构建了持续集成实用程序,它们让我们:
>构建和扩展在调试模式下测试 各种让我们选择GitLab的东西! 我们希望对整个库进行概述,并将基准推送到一个单独的项目中.我们已经使用SSH密钥方法完成了类似的文档,但是这次我们想避免这种情况. 我们尝试了这样的脚本: test_ci_push: tags: - linux - shell - light stage: profiling allow_failure: false only: - new-benchmark-stage script: - git clone http://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.mycompany.home/developers/benchmarks.git &> /dev/null - cd benchmarks - touch test.dat - echo "This is a test" > test.dat - git config --global user.name "${GITLAB_USER_NAME}" - git config --global user.email "${GITLAB_USER_EMAIL}" - git add --all - git commit -m "GitLab Runner Push" - git push http://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.mycompany.home/developers/benchmarks.git HEAD:master - cd .. 我们还尝试了一个基本的git push origin master来推送我们更新的文件,但每次我们得到相同的答案: remote: You are not allowed to upload code for this project. fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.mycompany.home/developers/benchmarks.git/': The requested URL returned error: 403 这两个项目都在同一个站点下,我有权同时推进这两个项目.我在哪里做错了什么?
gitlab ci令牌更像是github.com中的deploy键,因此它只具有对存储库的读访问权限.要实际推送,您需要生成个人访问令牌并使用它.
首先,您需要生成令牌,如图所示here in the gitlab documentation.确保同时检查读取用户和api范围.此外,这仅适用于GitLab 8.15及更高版本.如果您使用的是较旧的版本并且不希望升级,那么我可以向您展示一种替代方法,但它更复杂且安全性更低. 最后你的gitlab-ci.yml应该是这样的: test_ci_push: tags: - linux - shell - light stage: profiling allow_failure: false only: - new-benchmark-stage script: - git clone http://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.mycompany.home/developers/benchmarks.git &> /dev/null - cd benchmarks - touch test.dat - echo "This is a test" > test.dat - git config --global user.name "${GITLAB_USER_NAME}" - git config --global user.email "${GITLAB_USER_EMAIL}" - git add --all - git commit -m "GitLab Runner Push" - git push http://${YOUR_USERNAME}:${PERSONAL_ACCESS_TOKEN}@gitlab.mycompany.home/developers/benchmarks.git HEAD:master - cd .. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |