Optimizing GitLab CICD: running a single pipeline on the master branch - Stack Overflow

I have three stages of branches: local branch → staging → production.Right now, developers move their

I have three stages of branches: local branch → staging → production.

Right now, developers move their code to the staging branch, but I have three pipelines running in staging. I want to run only one pipeline on the master branch. How can I do that?

This is my current .yml file in GitLab:

stages:
  - deploy-staging
  - deploy-production

deploy-staging:
  stage: deploy-staging
  tags:
    - CD
  script:
    - echo "Staging deployment started."
    - echo updating gittestproject
    - ssh [email protected] 'cd /var/www/html/gittestproject; git pull origin staging'
    - echo "Deployment Succeed."
  rules:
    - if: '$CI_COMMIT_BRANCH == "staging"'   # Run only if on staging branch
  when: manual

deploy-production:
  stage: deploy-production
  tags:
    - CD
  script:
    - echo "Production deployment started."
    - echo updating gittestproject
    - ssh [email protected] 'cd /var/www/html/gittestproject_production; git pull origin master'
    - echo "Deployment Succeed."
  rules:
    - if: '$CI_COMMIT_BRANCH == "master"'  # Run only if on master branch
  when: manual

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744212957a4563422.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信