5

I'm writing a gitlab-ci.yaml script for my pipeline, and trying to define an array of strings variable (simplified version of the code):

npm_audit:
  variables:
    PACKAGE-WHITE-LIST: ["package A", "package B"]
  script:
   - npm install audit-ci
   - npx audit-ci -w PACKAGE-WHITE-LIST npm >> audit.log

When I run the pipeline, I get a yaml parse failure: "variables config should be a hash of key value pairs array"

What am I missing here?

omer
  • 1,242
  • 4
  • 18
  • 45

1 Answers1

-2

Your code is not working for some reasons :

  • Your variable can't contain dash
  • You forgot the $ before your variable name to retrieve its value
  • You don't need to create an array

The following definition should work :

  npm_audit:
  variables:
    PACKAGE_WHITE_LIST: "package A package B"
  script:
   - npm install audit-ci
   - npx audit-ci -w $PACKAGE_WHITE_LIST npm >> audit.log
metanerd
  • 713
  • 1
  • 6
  • 21
Nicolas Pepinster
  • 5,413
  • 2
  • 30
  • 48