无法触发我的默认(主)分支的管道
我一直在绕这个大脑,我觉得自己无处可去。我有一个项目,其代码托管在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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论