Skip to content
GitLab
Next
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 52,765
    • Issues 52,765
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,551
    • Merge requests 1,551
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #341154
Closed
Open
Issue created Sep 17, 2021 by Michael Friedrich@dnsmichi🌈Developer

!reference merging script array items looks odd in merged YAML view in pipeline editor

Summary

Referencing a script attribute with one or more array elements inside leads into a valid and working config, though the merged YAML view does not show the final merged array items. Instead, you'll get the referenced array object as new job script array item, a nested object-in-object view so to speak.

- (- script1 script2 script3)
- scriptcmd 

Depending on the programming language involved, this may lead to different results. Developers who investigate this may wonder what happened here. The merged array items should be presented instead.

Steps to reproduce

  1. New project + CI/CD > Pipeline Editor
  2. Use the following snippet to reproduce the error
stages:
  - lint  
  - test

.python-req:
  script:
    - pip install pyflakes

lint-python:
  extends: .python-req
  stage: lint
  image: python:latest
  script:
    - !reference [.python-req, script]
    - pyflakes python/

Example Project

What is the current bug behavior?

!reference merges both script sections accordingly, and the configured pipeline runs as excepted. The odd thing is that the View Merged YAML tab prints

stages:
- ".pre"
- lint
- test
- ".post"
".python-req":
  script:
  - pip install pyflakes
lint-python:
  script:
  - - pip install pyflakes
  - pyflakes python/
  extends: ".python-req"
  stage: lint
  image: python:latest

This gets worse when you reference more than 1 array element, e.g.

.python-req:
  script:
    - pip install -r python/requirements.txt
    - pip install pyflakes

lint-python:
  extends: .python-req
  stage: lint
  image: python:latest
  script:
    - !reference [.python-req, script]
    - pyflakes python/

gets merged into

stages:
- ".pre"
- lint
- test
- ".post"
".python-req":
  script:
  - pip install -r python/requirements.txt
  - pip install pyflakes
lint-python:
  script:
  - - pip install -r python/requirements.txt
    - pip install pyflakes
  - pyflakes python/
  extends: ".python-req"
  stage: lint
  image: python:latest

What is the expected correct behavior?

lint-python:
  script:
    - pip install pyflakes
    - pyflakes python/

Relevant logs and/or screenshots

image

From the second example with multiple script entries referenced.

image

Possible fixes

Probably the merged script array is processed later correctly, and the returned value for the merged yaml is just off in that regard. Or we are using a Ruby/Go type method to merge arrays automatically at some point, without controlling it ourselves.

The array merger result is what the merged YAML view (and API endpoint) need to provide.

cc @dhershkovitch @jreporter

Assignee
Assign to
Time tracking