Anchors and include

i use lot of anchors for split big yml script and for by this way réuse the code in several job script, but seem not possible to save anchors into separate file include and to load them in yml main scripts, main script must contain also the anchors, i saw lot of request on it.

My question when gitlab will implement the feature include yml with anchors only. I read same issue with extends. but i my case i need anchors. An idea on which version that will be implemented ?
i use actually 12.6.6

myanchors_utils.yml

.a: &a
- echo “a”
.f: &f
- echo “f”
e: &e
- echo “e”

mymain1.yml
include:
local: “myanchors_utils.yml”
job15:
script:
- *a
- *e
I read same issue with extends. but i my case i need anchors.

mymain2.yml
include:
local: “myanchors_utils.yml”
job1:
script:
- *f
- *a
etc …
For the moment i must duplicate the code in each main yml, not funny

Thanks for your answer and idea

I have a similar problem. I have a list of script segments accessible via yaml anchors.
As this list of script segments are the same for all projects but which segments are used
in the projects I would like to externalize the segments into an own yaml file and include it.

E.g. I looks like this:

// .gitlab-aspects.yaml
# Do some commands specific to aspectA
.aspectA: &aspectA
- ‘install stuff’
- ‘export SOME_ENV=specific_to aspectA’

# Do some commands specific to aspectB
.aspectB: &aspectB
  - 'install other stuff'
  - 'export SOME_OTHER_ENV=specific_to aspectB'

# and the list go one

The template is then used in the real .gitlab-ci.yaml file:

// .gitlab-ci.yaml
include: ‘.gitlab-aspects.yaml’

job1:
	stage: build
	before_script:
	  - *aspectA
	  - *aspectC
	script:
	  - 'do the job1 stuff here'
	  
job1:
	stage: build
	before_script:
	  - *aspectB
	  - *aspectC
	  - *aspectD
	script:
	  - 'do the job2 stuff here'

So the trick with extends job does not work, as the script arrays are not merged.
Is there a fundamental reason which yaml anchors won’t work? It would help immensely
if yaml anchors combined with include would work.

Best regards,
Dieter