Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append the script on one stage .gitlab-ci.yml

How to append the script section in one stage in the .gitlab-ci.yml file?

e.g in this example

stages:
  - stage1_name

.a:
  script:
    - echo "String 1"

.b:
  script:
    - echo "String 2"


stage1_name:
  stage: stage1_name
  extends: .a
  extends: .b
  script:
    - echo "String 3"

how to get as output:

String 1
String 2
String 3

instead of:

String 3
like image 389
Triumf Maqedonci Avatar asked Feb 19 '26 05:02

Triumf Maqedonci


1 Answers

Gitlab 13.9 introduced a !reference-tag which makes this possible;

.setup:
  script:
    - echo creating environment

test:
  script:
    - !reference [.setup, script]
    - echo running my own command
like image 146
Ferdy Avatar answered Feb 20 '26 21:02

Ferdy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!