title: Set variables depending on Gitlab rules
body: <p>We have 2 environments (development, production). Per default we deploy to production but if the branch name or the commit message start with <em><strong>dev</strong></em> we deploy to development environment.</p>
  <p>I create variables (<em><strong>app_url</strong></em> and <em><strong>app_url_dev</strong></em>) via gitlab GUI : (Project =&gt; Settings =&gt; CI/CD =&gt; Variables)</p>
  <p>I use gitlab rule to change the <em><strong>app_url</strong></em> variable of deployement. The script <em><strong>deploy.py</strong></em> (and many other scripts) are using <em><strong>app_url</strong></em> variable.</p>
  <p>The gitlab-ci code is:</p>
  <pre><code>Tags:
    stage: Deploy code
    rules:
    #    - if: $CI_COMMIT_REF_NAME == &quot;main&quot; &amp;&amp; $CI_COMMIT_MESSAGE =~ /^dev/
        - if: $CI_COMMIT_REF_NAME == &quot;main&quot; &amp;&amp; $CI_COMMIT_BRANCH =~ /^dev/
          variables:
            app_url: $app_url_dev
    script:
    - Python deploy.py 
  </code></pre>
  <p>The problem is that i never get the value of app_url_dev in app_url. I tried other combinaison but i always get the production url and not the dev one:</p>
  <pre><code>app_url: ${app_url_dev}
  app_url: app_url_dev
  </code></pre>
  <p>But i get always the <em><strong>app_url</strong></em> and not the <em><strong>app_url_dev</strong></em>.
  Anyone can help please ?</p>