Julio
Julio

Reputation: 11

curl command not working on gitlab-ci pipeline

I am trying to pull a project ID using gitlab REST API v4, but when I issue the curl command, I get this error:

"jobs:test:script config should be a string or an array of strings"

The command is this one:

I tried to single quote it:

But when I do it, it removes the failure, but the command is ignored. So I tried to eval it like this:

When I do it, the failure its produced again:

"jobs:test:script config should be a string or an array of strings"

Any clue how should I issue the curl command? I think what is causing the failure is the colon within the "PRIVATE-TOKEN: PRIVATE-TOKEN"

Upvotes: 1

Views: 3627

Answers (1)

Naeem Shaikh
Naeem Shaikh

Reputation: 11

This worked for me

Declare Job variables in variables sections eg:

  • variables:
    • PRIVATE-TOKEN: "TokenValue"
    • PRIVATE_HEADER: "PRIVATE-TOKEN: ${PRIVATE-TOKEN}"

Then under Script Section of the CI file used Curl command as follows

  • script:
    • curl -k -H ${PRIVATE_HEADER} "https://gitlab.nbg992.poc.dcn.telekom.de/api/v4/projects?search=${CI_PROJECT_NAME}

Using the {} braces around variable names made sure that ":" issue doesn't show up

Upvotes: 1

Related Questions