无法触发我的默认(主)分支的管道

发布于 2025-01-19 02:55:56 字数 1564 浏览 0 评论 0原文

我一直在绕这个大脑,我觉得自己无处可去。我有一个项目,其代码托管在gitlab上。我的项目有两个分支,开发main。我对开发分支进行更改,推动这些更改我的登台实例的更改。当我准备部署实时更改时,我将与main合并,这旨在触发我的实例部署。这是我的gitlab-ci.yml文件,

default:
  image: docker:19.03.10
  tags:
    - docker
    
.deployment_script: &deployment_script
  - echo "Starting deployment to ECS ..."
  - echo "So many lines here that deploy code to aws ecs"

services:
  - docker:dind

variables:
  REPOSITORY_URL: **********.dkr.ecr.**-****-*.amazonaws.com/********/****

before_script:
  - echo "Creating image tag ..."
  - IMAGE_TAG="$(echo $CI_COMMIT_SHA | head -c 8)"

stages:
  - build
  - deploy

build:
  stage: build
  script:
    - echo $DEPLOY_ENVIRONMENT ...
    - echo "The script here build my docker container and publishes to aws ecr"
    - echo "Build is only meant to be ran when pushing to develop"
  rules:
    - if: '$CI_COMMIT_BRANCH == "develop"'
      when: always        

deploy-staging:
  environment: staging
  dependencies:
    - "build"
  image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
  script:
    - *deployment_script
  rules:
    - if: '$CI_COMMIT_BRANCH == "develop"'
      when: manual

deploy-production:
  environment: production
  image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
  script:
    - *deployment_script
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
      when: manual

每次我部署到开发分支时,都会触发管道,我成功地部署了我的登台应用程序。但是,无论我推了多少次main,都没有触发。我不知道为什么。我希望有人也能指出正确的方向。

I have been racking my brain around this and I feel like I am going nowhere. I have a project whose code is hosted on Gitlab. My project has two branches, develop and main. I make changes on my develop branch, push these changes which updates my staging instance. When I am ready to deploy live changes, I merge with main which is meant to trigger a deployment to my live instance. This is my gitlab-ci.yml file

default:
  image: docker:19.03.10
  tags:
    - docker
    
.deployment_script: &deployment_script
  - echo "Starting deployment to ECS ..."
  - echo "So many lines here that deploy code to aws ecs"

services:
  - docker:dind

variables:
  REPOSITORY_URL: **********.dkr.ecr.**-****-*.amazonaws.com/********/****

before_script:
  - echo "Creating image tag ..."
  - IMAGE_TAG="$(echo $CI_COMMIT_SHA | head -c 8)"

stages:
  - build
  - deploy

build:
  stage: build
  script:
    - echo $DEPLOY_ENVIRONMENT ...
    - echo "The script here build my docker container and publishes to aws ecr"
    - echo "Build is only meant to be ran when pushing to develop"
  rules:
    - if: '$CI_COMMIT_BRANCH == "develop"'
      when: always        

deploy-staging:
  environment: staging
  dependencies:
    - "build"
  image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
  script:
    - *deployment_script
  rules:
    - if: '$CI_COMMIT_BRANCH == "develop"'
      when: manual

deploy-production:
  environment: production
  image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
  script:
    - *deployment_script
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
      when: manual

Every time I deploy to the develop branch, the pipelines are triggered and I successfully deploy my staging application. However, no matter how many times I push to main, nothing is triggered. I have no idea why. I hope someone can point me in the right direction too figure this out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文