I'm trying to run a pipeline job in GitLab CI to perform npm build but only if a package.json exists in the project that triggers the upstream pipeline. I used 'needs:' to download files from the upstream pipeline. When the pipeline job runs I get an error stating: jobs:packages.react:rules:rule exists should be an array of strings
. I checked the GitLab documentation for rules:exists:project and the YAML syntax is correct. I made sure the YAML is indented correctly. How do I solve the error?
Here's the code:
packages.react:
stage: app-build
needs:
- project: $UPSTREAM_PROJECT_PATH
job: get-source-files
ref: $UPSTREAM_BRANCH_REF
artifacts: true
rules:
- exists:
paths:
- package.json
project: $UPSTREAM_PROJECT_PATH
image: $NODE_IMAGE
script:
- npm install --frozen-lockfile
- npm run build
I figured out the issue. It's due to the version of GitLab I'm using, which is 16.9. The 'rules:exists:project' feature does not exist in version 16.9, only in version 16.11 and above. I have a self managed GitLab instance so I will need to upgrade to 16.11.