gitlab-ci 中的 token

创建

个人 -> 设置 -> access token 中创建 CI_TAG_UPLOAD_TOKEN

使用

创建后,再到项目中的 设置 -> CI/CD -> secret values 中创建 CI_TAG_UPLOAD_TOKEN,并把值设置为前面生成的值。

gitlab-ci.yml 文件的脚本中设置

1
2
3
script:
- url_host=`git remote get-url origin | sed -e "s/https:\/\/gitlab-ci-token:.*@//g"`
- git remote set-url origin "https://gitlab-ci-token:${CI_TAG_UPLOAD_TOKEN}@${url_host}"