Rules:If can't concatenate variables

Thought I’d post this here first in case I am doing something wrong before I log it as an issue.

As the title suggests, whenever I try to create a variable by joining a string and another variable, or, running a rules: if statement on a string joined with a variable it never evaluates correctly. To demonstrate my point, here is a simple yml file to test:

  a: "powershell"
  b: "whizz"
  bot: "powershell${b}"
    - if: $GITLAB_USER_LOGIN  == $bot
    echo $bot

In the above example my username is powershellwhizz and the debug job should execute everytime I update the repo with a change, ONLY if executed by me. I then update any file as me to trigger the job but it never does so. If I change the $bot variable to the string “powershellwhizz” it then works, it’s as if the rules can’t see the variable inside the string. Here are the variations I have tried on the $bot variable and none of them work:


The 'powershell"$b"' one is directly from the doco here which suggests it should work GitLab CI/CD variables | GitLab. Extract below:

Use variables in other variables

You can use variables inside other variables:

    FLAGS: '-al'
    LS_CMD: 'ls "$FLAGS"'
    - 'eval "$LS_CMD"'  # Executes 'ls -al'
1 Like