Use Hiera alias in Gitlab CI/CD using variable in lookup

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:

    DEPLOY_TYPE: 'drupal'
    script_name: 'build-$DEPLOY_TYPE'

.drupal_template: &build-drupal
    - echo "Drupal test"

.symfony_template: &build-symfony
    - echo "Symfony test"

    image: alpine
    stage: build

    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-symfony , build-frontend-drupal ) and include them using rules.

      - if: '$DEPLOY_TYPE == "drupal"'

      - if: '$DEPLOY_TYPE == "symfony"'

Unfortunately 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.

Reopend in Use yaml alias in Gitlab CI/CD using variable in lookup With correct title.

This one can be closed.