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,968
    • Issues 36,968
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 1,426
    • Merge requests 1,426
  • 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
  • #215662

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

Empty `only`/`except` combined with `rules` (and vice-versa) should be a valid CI config

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 job-a is defined in a template.

While the error is preventing clashing conditions, it would be great to be able to make the only/except empty so that we don't get the validation error:

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

job-b:
  extends: job-a
  only: {}
  except: {}
  rules:
    - if: '$CI_MERGE_REQUEST_ID'
  script: echo "bar"

The above seems intuitive and in line with how you can make other keywords empty (e.g. before_script: [] or dependencies: [] are familiar patterns).

This proposal would solve #31371 (closed) (which I'm going to close in favor of this actionable proposal).

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, rules: [], i.e. the following should be valid as well:

    job-a:
      rules:
        - if: '$CI_MERGE_REQUEST_ID'
      script: echo "foo"
    
    job-b:
      extends: job-a
      rules: []
      only:
        refs:
          - master
      except:
        refs:
          - merge_requests
      script: echo "bar"
Edited Apr 27, 2020 by Rémy Coutable
Assignee
Assign to
Backlog
Milestone
Backlog
Assign milestone
Time tracking