title: How to merge rules on a GitLab CI Job
body: <p>Let's suppose I have this hidden &quot;base&quot; job.</p>
  <pre class="lang-yaml prettyprint-override"><code>.base_job:
    rules:
      - if: &quot;$CI_COMMIT_TAG&quot;
        when: never
      - if: '$CI_PIPELINE_SOURCE == &quot;web&quot;'
  </code></pre>
  <p>I'd like to add these rules to a new job and be able to extend them too, e.g.:</p>
  <pre class="lang-yaml prettyprint-override"><code>job_1:
    rules:
      - &lt;add .base_job here&gt;
      - if: &quot;$CI_MERGE_REQUEST_IID&quot;
  
  
  job_2:
    rules:
      - &lt;add .base_job here&gt;
      - if: &quot;$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH&quot;
  </code></pre>
  <p>Note that <code>job_1</code> and <code>job_2</code> have different rules, including the ones from <code>.base_job</code>.</p>
  <p>If I were to use <code>extends</code>, the jobs would have only the custom rule because according to the <a href="https://docs.gitlab.com/ee/ci/yaml/#merge-details" rel="noreferrer">docs</a>:<br />
  <code>You can use extends to merge hashes but not arrays.</code></p>
  <p>My solution so far is to copy-paste the rules for both jobs but I'd like to keep it more DRY.</p>
  <p>Any tips on how to do it?</p>