!reference not working in multi line commands
Summary
!reference tags are not evaluated in multi line commands. It would be great to have that as a possibility since we use it to reuse code. Especially in conditions or loops it is currently not directly possible to reuse code.
Steps to reproduce
Have a !reference tag inside a multi line command
.gitlab-ci.yml
stages: # List of stages for jobs, and their order of execution
- build
build-job: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "Compiling the code..."
- |
echo "This is a multi line command"
!reference [.reused-script, script]
- echo "Compile complete."
.reused-script:
script:
- echo "This is working"
Actual behavior
The !reference tag ist not replaced by the referenced code.
Expected behavior
The !reference tag ist replaced by the referenced code.
Output: This is a multi line command This is working
Relevant logs and/or screenshots
job log
Running with gitlab-runner 15.2.0 (7f093137)
on Local machine(Thore) e2Lk-y91
Resolving secrets
00:00
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:05
Running on DEAGM11951...
Getting source from Git repository
00:05
Fetching changes with git depth set to 20...
Initialized empty Git repository in C:/Program Files/gitlab-runner/builds/e2Lk-y91/0/staecth/gitlab-ci-test/.git/
Created fresh repository.
Checking out 6838ad89 as main...
git-lfs/3.2.0 (GitHub; windows amd64; go 1.18.2)
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
$ echo "Compiling the code..."
Compiling the code...
$ echo "This is a multi line command" # collapsed multi-line command
This is a multi line command
!reference:
Line |
232 | !reference [.reused-script, script]
| ~~~~~~~~~~
| The term '!reference' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit status 1
Edited by Darren Eastman