I'm trying to create a tag from a job using Tags API. Can I do it using job token or a private token is necessary? When I try creating a tag using JOB_TOKEN
I get Invoke-WebRequest : {"message":"404 Project Not Found"}
as a response.
$tagName = [Uri]::EscapeDataString($env:FULL_PRODUCT_VERSION)
$ref = [Uri]::EscapeDataString($env:CI_COMMIT_SHA)
$createTagApiEndpoint = "$env:CI_API_V4_URL/projects/$env:CI_PROJECT_ID/repository/tags?tag_name=$tagName&ref=$ref"
$headers = @{"JOB-TOKEN" = $env:CI_JOB_TOKEN}
Invoke-WebRequest -Headers $headers -Method POST -Uri $createTagApiEndpoint
CodePudding user response:
It is only possible to use the JOB_TOKEN
if the ci_job_token_scope
feature is enabled, as described in the docs:
Feature.enable(:ci_job_token_scope)
It is disabled by default.