最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin5浏览0评论

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
发布评论

评论列表(0)

  1. 暂无评论