Pipeline / Job variables of type "File" don't preserve line breaks

Summary

When starting pipelines or jobs manually, we can provide variables. We can choose between the two types Variable and File. Just like in the Project > Settings > CI/CD > Variables. But unlike there, line breaks in variables of the type File are not preserved.

https://gitlab.com/trallnag/showcase-bug-variable-file-linebreaks

Steps to reproduce

  1. Create a .gitlab-ci.yml with the following content. Commit and push. You can ignore / cancle the pipeline that gets triggered now automaticaly.

    stages:
      - main
    
    main:
      stage: main
      script:
        - cat $var_file_type_from_project
        - cat $var_file_type_from_pipeline
  2. Go to "CICD > Pipelines > Run Pipeline" and set a variable of the type File with the name var_file_type_from_pipeline. Paste into the value field the following multiline string. You will see that the line breaks are removed.

    line1
    line2
  3. Run the pipeline and check the logs. The line breaks are removed.

    image

  4. Now we compare this to variables of the type File set in the project settings.

    image

  5. Run the pipeline and check the logs. The line breaks are preserved. This is the expected behavior.

    image

Example Project

https://gitlab.com/trallnag/showcase-bug-variable-file-linebreaks

What is the current bug behavior?

Line breaks are removed.

What is the expected correct behavior?

Line breaks should be preserved just like with File variables set in the project settings.

Results of GitLab environment info

gitlab.com

Edited by Tim Schwenke