For Gitlab CI/CD i’m using templates in one central repository to be able to manage all pipeline config from one place. I’m using the pipelines to build and deploy applications using Drupal, Symfony and Wordpress Bedrock.
I want to make the following code work within Gitlab CI/CD to be able to use
needs: in my stages for DAG:
variables: DEPLOY_TYPE: 'drupal' script_name: 'build-$DEPLOY_TYPE' .drupal_template: &build-drupal - echo "Drupal test" .symfony_template: &build-symfony - echo "Symfony test" build-fontend: image: alpine stage: build script: *build-$DEPLOY_TYPE another-step: image: alpine stage: deploy needs: ["build-frontend", "build-backend"]
Is there any way to include the correct alias using a variable in the name?
In my current setup I use different names for the different deploy types (
build-frontend-drupal ) and include them using rules.
build-frontend-drupal: ... rules: - if: '$DEPLOY_TYPE == "drupal"' ... build-frontend-symfony: ... rules: - if: '$DEPLOY_TYPE == "symfony"' ...
needs: doesn’t allow variables either.
I searched the documentation for Gitlab and Yaml but without success.
Other ideas to make this work are welcome ofcourse!
Thanks for the help.