cUrl Post Request in CI/CD Pipeline


I am currently trying to call an API from a CI/CD pipeline.
I’ve been able to run a GET request but found out that I’d like to pass some metadata as well with a POST request

I’m almost there, but I’ve been stuck with CI/CD not reading/accessing the pipeline variables as I hoped.

Working GET and POST request is structured like this:

  stage: auto_deploy
    - test-qa
     - 'curl --request GET -H "ApiKey: $ApiKeyQA" -H "Deploytoken: $QA_DEPLOY_TOKEN" "$QA_DEPLOY_SERVICE_URL""$CI_PROJECT_NAME/"'

    - curl --request POST -H "ApiKey:$ApiKeyQA" -H "Deploytoken:$QA_DEPLOY_TOKEN" -H "Content-Type:application/json" -d '{ "environment":"qa", "repo_name":"$CI_PROJECT_NAME", "pr_message":"$CI_COMMIT_TITLE" }' $QA_DEPLOY_URL_POST

They both currently run and work, but the CI variables in the POST request are " $ci_project_name and $CI_COMMIT_TITLE", when I read it on the API side meaning they are not read/accessed correctly in the pipeline.

I’ve tried many variations and tried to Google around, but have not found any viable solutions yet. Would appreciate some feedback!


Hey Anton,

Could you try writing your variables in the JSON part of your request as ${CI_PROJECT_NAME} - note the curly brackets?


'{ "environment":"qa", "repo_name":"${CI_PROJECT_NAME}", "pr_message":"${CI_COMMIT_TITLE}" }'

Kind regards,

I did that and it seems like the API is getting just the dollar sign $, I’ll have to debug to see what the payload is currently