Failing pipeline job with package publishing
Using the same file .gitlab-ci.yml does not work for some repositories while for other it does.
Script failure error:
Could not create package - Code 400 - {"message":"Validation failed: Name is already taken by another project"}
It is working like a charm on brand new repositories same as same old ones, but we did came across few with mentioned error above. There is no already existing package in the group with same ‘composer’ name so I really don’t get the issue here. There is even no existing package in repository in any branch.
Configuration is really a default .gitlab-ci.yml file, with content like this:
# This file is a template, and might need editing before it works on your project.
# Publishes a tag/branch to Composer Packages of the current project
publish:
image: curlimages/curl:latest
stage: build
variables:
URL: "$CI_SERVER_PROTOCOL://$CI_SERVER_HOST:$CI_SERVER_PORT/api/v4/projects/$CI_PROJECT_ID/packages/composer?job_token=$CI_JOB_TOKEN"
script:
- version=$([[ -z "$CI_COMMIT_TAG" ]] && echo "branch=$CI_COMMIT_REF_NAME" || echo "tag=$CI_COMMIT_TAG")
- insecure=$([ "$CI_SERVER_PROTOCOL" = "http" ] && echo "--insecure" || echo "")
- response=$(curl -s -w "\n%{http_code}" $insecure --data $version $URL)
- code=$(echo "$response" | tail -n 1)
- body=$(echo "$response" | head -n 1)
# Output state information
- if [ $code -eq 201 ]; then
echo "Package created - Code $code - $body";
else
echo "Could not create package - Code $code - $body";
exit 1;
fi
Any suggestion will be welcome. Thank you.