Hi,
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:
auto_deploy:
stage: auto_deploy
only:
- test-qa
script:
- '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!
Thanks,
Anton