Ashish Pratap
Ashish Pratap

Reputation: 479

How to replace except tags and pushes in gitlab-ci.yml file with rules?

I have a ci-cd pipeline where I am using the following except condition currently:

except:
    - tags
    - pushes

With the increasing conditions, now I have to use rules. I cannot use only and except with rules now. Can someone help me with this?

I have tried the following snippet:

rules:
      - if: 'tags && pushes'
        when: never

But this gives the following error:

jobs:build_info:rules:rule if invalid expression syntax

Upvotes: 2

Views: 3419

Answers (1)

ericfossas
ericfossas

Reputation: 2196

Use predefined environment variables:

rules:
 - if: '$CI_PIPELINE_SOURCE == "push" || $CI_COMMIT_TAG != null'
   when: never

Upvotes: 5

Related Questions