Manually deploy to environment
Hello,
I am trying to create a more dynamic way to create jobs when I set an environment variable to the pipeline. When I want to run this job in the dev environment: I manually trigger the pipeline and enter the following variable. - ENV = dev - DEPLOY = TRUE
This is what I first tried and it didn't work
.openshift-installer_template: &openshift-installer_template
stage: openshift-installer
image: mtb-docker-temp/ose-devopenshift-installer:${RUNNERIMAGETAG}
script:
- terraform apply -auto-approve -var-file="terraform.tfvars" -var "vsphere_password=${VSPHERE_PASSWORD}" ${CI_PROJECT_DIR}/vsphere
artifacts:
paths:
- $CI_PROJECT_DIR/${CI_ENVIRONMENT_NAME}
expire_in: 1 week
rules:
- if: '$DEPLOY =~ /TRUE/ && $ENV =~ /${CI_ENVIRONMENT_NAME}/'
when: manual
lab-openshift-installer:
environment:
name: lab
<<: *openshift-installer_template
sbx-openshift-installer:
environment:
name: sbx
<<: *openshift-installer_template
dev-openshift-installer:
environment:
name: dev
<<: *openshift-installer_template
This works but it's not dynamic.
.openshift-installer_template: &openshift-installer_template
stage: openshift-installer
image: mtb-docker-temp/ose-devopenshift-installer:${RUNNERIMAGETAG}
script:
- terraform apply -auto-approve -var-file="terraform.tfvars" -var "vsphere_password=${VSPHERE_PASSWORD}" ${CI_PROJECT_DIR}/vsphere
artifacts:
paths:
- $CI_PROJECT_DIR/${CI_ENVIRONMENT_NAME}
expire_in: 1 week
lab-openshift-installer:
<<: *openshift-installer_template
environment:
name: lab
rules:
- if: '$DEPLOY =~ /TRUE/ && $ENV =~ /lab/'
when: manual
sbx-openshift-installer:
<<: *openshift-installer_template
environment:
name: sbx
rules:
- if: '$DEPLOY =~ /TRUE/ && $ENV =~ /sbx/'
when: manual
dev-openshift-installer:
<<: *openshift-installer_template
environment:
name: dev
rules:
- if: '$DEPLOY =~ /TRUE/ && $ENV =~ /dev/'
when: manual
Any advice of how to do this more efficiently? Our pipeline is getting very long when having to duplicate rules.
Edited by Gabriel Virga