I try to make a release with a GitLab-CI job by using GitLab API and cURL (cURL.exe
within PowerShell).
But the GitLab variables converting are failed... (I tried several formats without any success)
release_job:
stage: release
tags:
- windows-powershell
rules:
- if: $CI_COMMIT_TAG
script:
- curl.exe --data '{\"tag_name\":\"'"$CI_COMMIT_TAG"'\", \"name\":\"'"$CI_COMMIT_TAG"'\", \"ref\":\"'"$CI_COMMIT_SHORT_SHA"'\"}' --header "Content-Type:application/json" --header "PRIVATE-TOKEN:<my_private_token>" --request POST "https://<my_gitlab>/api/v4/projects/388/releases"
When I convert myself the GitLab variables the script status is success.
release_job:
stage: release
tags:
- windows-powershell
rules:
- if: $CI_COMMIT_TAG
script:
- curl.exe --data '{\"tag_name\":\"v0.1\", \"name\":\"v0.1\", \"ref\":\"05974ba7\"}' --header "Content-Type:application/json" --header "PRIVATE-TOKEN:<my_private_token>" --request POST "https://<my_gitlab>/api/v4/projects/388/releases"
Can you help me to understand please. In advance, thank you.
CodePudding user response:
PRIVATE-TOKEN:$env:TOKEN_VAR_NAME
CodePudding user response:
The solution is:
curl.exe --data "{\`"tag_name\`":\`"$CI_COMMIT_TAG\`", \`"name\`":\`"$CI_COMMIT_TAG\`", \`"ref\`":\`"$CI_COMMIT_SHORT_SHA\`"}" --header "Content-Type:application/json" --header "PRIVATE-TOKEN:<my_private_token>" --request POST "https://<my_gitlab>/api/v4/projects/388/releases"