Skip to content

GitLab Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
GitLab
GitLab
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 36,926
    • Issues 36,926
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 1,459
    • Merge requests 1,459
  • Requirements
    • Requirements
    • List
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Metrics
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLabGitLab
  • Issues
  • #215664

Closed
Open
Created Apr 24, 2020 by Rémy Coutable@rymai🔴Maintainer

Child job `rules` should always take precedence over parent job's `only`/`except` (and vice-versa)

Currently, if I have the following CI config:

job-a:
  only:
    refs:
      - master
  except:
    refs:
      - merge_requests
  script: echo "foo"

job-b:
  extends: job-a
  rules:
    - if: '$CI_MERGE_REQUEST_ID'
  script: echo "bar"

I get a validation error:

jobs:job-b config key may not be used with `rules`: only, except

Note that we get the same problem if jobA is defined in a template.

While the error is preventing clashing conditions, it would be great if rules from a child job could always take precedence over only/except of its parent job so that we don't get the validation error (i.e. only/except would be dropped for the job-b job since it declare rules).

Notes:

  1. That this proposal should work the same if job-a is defined in a template.

  2. The same thing should apply to rules (i.e. rules would be dropped for the job-b job since it declare only/except):

    job-a:
      rules:
        - if: '$CI_MERGE_REQUEST_ID'
      script: echo "foo"
    
    jobb:
      extends: job-a
      only:
        refs:
          - master
      except:
        refs:
          - merge_requests
    script: echo "bar"

This proposal would greatly ease the update of our devopssecure templates from only/except to rules (&2300 (closed)) and allow to not make this update a breaking change.

Edited Apr 29, 2020 by Rémy Coutable
Assignee
Assign to
Backlog
Milestone
Backlog
Assign milestone
Time tracking