I am quite new in gitlab environment and working on how to reuse code as possible in our pipelines. I was trying to use !reference in the following scenario:
common.yml
.test1:
changes:
- somelistpath
.test2:
changes:
- anotherpath
.all:
changes:
- !reference [.test1, changes]
- !reference [.test2, changes]
then .build-template:
spec:
inputs:
stage:
default: build
changes:
description: "Paths job needs to run their rules against"
default: []
type: array
tags:
default:
- linux
description: "Tags used during Job run. Right now we use windows or linux to choose runner"
type: array
---
.default_build_rules:
rules:
- if: '$CI_COMMIT_BRANCH == "develop"'
- if: '$CI_COMMIT_BRANCH =~ /^release/.*$/'
- if: '$CI_COMMIT_BRANCH =~ /^hotfix/.*$/'
- if: '$CI_PIPELINE_SOURCE == "web"'
- if: '$CI_PIPELINE_SOURCE == "webide"'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: $[[inputs.changes]]
...
then .appbuild-ci.yml
include:
- local: "/buildTemplates/.common.yml"
- local: "/buildTemplates/.build-template.yml"
inputs:
changes:
- !reference [ .all, changes]
app-build-job:
extends:
- .common-build-job
- .common-build-cache-job
before_script:
- echo specific job
script:
- cd testapp
- npm install
- npm build
I receive an error in jobs:app-build-job:rules:rule:changes config should be an array of strings.
When I check the full configuration section .defaul-build-rules looks good:
".common-build-job":
stage: build
tags:
- linux
rules:
- - if: "$CLEAR_DOCKER != null"
when: never
- - if: $CI_COMMIT_BRANCH == "develop"
- if: "$CI_COMMIT_BRANCH =~ /^release\/.*$/"
- if: "$CI_COMMIT_BRANCH =~ /^hotfix\/.*$/"
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "webide"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- !reference
data: &1
:tag: "!reference"
:style: 1
:seq:
- ".all"
- changes
:scalar:
:map: {}
resolved_status: :done
resolved_value: &2
- - somelistpath
- - anotherpath
interruptible: true
before_script:
- echo template build
artifacts:
when: always
expire_in: 1 day
paths:
- _artifacts/publish/*
but app-build-job does not have a good rules section defined:
app-build-job:
stage: build
tags:
- linux
rules:
- - if: "$CLEAR_DOCKER != null"
when: never
- - if: $CI_COMMIT_BRANCH == "develop"
- if: "$CI_COMMIT_BRANCH =~ /^release\/.*$/"
- if: "$CI_COMMIT_BRANCH =~ /^hotfix\/.*$/"
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "webide"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- !reference
data: *1
resolved_status: :done
resolved_value: *2
That resolved_value: *2 confuses me and I have no idea why this was resolved as that value. Does anyone have any ideas? I appreciate any help you can provide.