2

The .gitlab-ci.yml file can accept the keyword: image, "to specify a Docker image that the job runs in."

I have encountered that the input entries of this keyword are sometimes enclosed with quotation marks (" ").

For example:

image: alpine

vs

image: "alpine"

GitLab Docs also contains both instances (sort of): quoted entry vs unquoted entry.

Could you please tell me whether there is any meaning of these quotation marks? If so, what is its meaning, and when should we use it?

sytech
  • 29,298
  • 3
  • 45
  • 86
Herpes Free Engineer
  • 2,425
  • 2
  • 27
  • 34

1 Answers1

1

Quotation marks are only significant with respect to YAML syntax and nothing else. GitLab always reads YAML according to the YAML specification. In the case you mention, alpine and "alpine" are parsed identically, there is no functional difference.

See also: YAML: Do I need quotes for strings in YAML?

In some cases, you need quotes to avoid YAML interpreting your strings as other kinds of YAML types. For instance: key: 123 is not the same as key: "123" for example.

As another example, if your string happens to start with a * you will need quotes to avoid it being interpreted as a YAML anchor:

# good:
artifacts:
  paths:
    - "*package.json"

# bad
artifacts:
  paths:
    - *package.json
sytech
  • 29,298
  • 3
  • 45
  • 86