Alex Montoya
Alex Montoya

Reputation: 5089

Error in yml gitlab CI/CD

I have this in gitlab-ci.yml

build_api:
 stage: build
 script:
  - docker build --pull -t $CONTAINER_TEST_IMAGE .
  - docker push $CONTAINER_TEST_IMAGE
only:
 ---->  variables:  <----- Error
    - $CI_COMMIT_MESSAGE == /\[pipeline\]|(merge)/i      
except:
  - master

In CI Lint in gitlab say *Error* : jobs:build_api:only variables invalid expression syntax

why its the reason ?

Upvotes: 4

Views: 7715

Answers (1)

avolkmann
avolkmann

Reputation: 3105

Have a look at this page: https://docs.gitlab.com/ce/ci/variables/README.html#variables-expressions

It seems you have to use =~ when matching patterns. Try

- $CI_COMMIT_MESSAGE =~ /\[pipeline\]|(merge)/i 

Double equals == only accepts strings, null, or variables.

Upvotes: 2

Related Questions