Cannot push from gitlab-ci.yml

后端 未结 3 1560
礼貌的吻别
礼貌的吻别 2020-12-23 12:18

With my colleagues, we work on a C++ library that becomes more and more important each day. We already built continuous integration utilities through the gitlab-ci.yml

3条回答
  •  一生所求
    2020-12-23 12:42

    You could also provide user and password (user with write access) as secret variables and use them.

    Example:

    before_script:
     - git remote set-url origin https://$GIT_CI_USER:$GIT_CI_PASS@gitlab.com/$CI_PROJECT_PATH.git
     - git config --global user.email 'myuser@mydomain.com'
     - git config --global user.name 'MyUser'
    

    You have to define GIT_CI_USER and GIT_CI_PASS as secret variables (you could always create dedicated user for this purpose).

    With this configuration you could normally work with git. I'm using this approach to push the tags after the release (with Axion Release Gradle Pluing - http://axion-release-plugin.readthedocs.io/en/latest/index.html)

    Example release job:

    release:
      stage: release
      script:
        - git branch
        - gradle release -Prelease.disableChecks -Prelease.pushTagsOnly
        - git push --tags
      only:
       - master
    

提交回复
热议问题