代码之家  ›  专栏  ›  技术社区  ›  LP13

如何在Gitlab管道中的特定标签处拉取分支

  •  0
  • LP13  · 技术社区  · 3 年前

    有没有办法 deploy-prod 我的GitLab管道中的作业 main 在特定的版本标记处分支,而不是总是提取最新的代码?这里$VERSION_NUMBER是管道中可用的变量

    deploy-prod:
      tags:
        - prod-runner
      image: docker.xxx/nodejs:14
      stage: deploy-prod
      environment: 
        name: prod
      script:
        - npm install        
        - npx sequelize-cli db:migrate
      when: manual
      rules:
        - if: $VERSION_NUMBER != ''
    
    0 回复  |  直到 3 年前
        1
  •  1
  •   Shashank Sinha    3 年前

    你可以跑步 before_script 要获取所有标记并在脚本中通过传递 VERSION_NUMBER

    before_script:
      - git fetch --tags
    
    script:
      - git checkout tags/${VERSION_NUMBER}
      # Your commands here...
    
    推荐文章