commit-and-tag: api tags 404 not found
Description
The commit-and-tag command fails in the project with an 404 http status.
$ release --ci-commit-tag $RELEASE_VERSION add-download-link --name release --url $RELEASE_URL --description "$RELEASE_DESC"
GET https://gitlab.com/api/v4/projects/carlosrivas/club/repository/tags/3.0.0: 404 {message: 404 Tag Not Found}
Not trying to continue after this kind of error.
If you think recovery should be attempted, please create an issue
at https://gitlab.com/juhani/go-semrel-gitlab/issues/new
or by email incoming+juhani/go-semrel-gitlab@incoming.gitlab.com
2020/07/01 12:30:38 workflow execution failed
ERROR: Job failed: exit code 1
Investigation
It appears that the problem is related with the url called
Using curl:
$ curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.com/api/v4/projects/carlosrivas/club/repository/tags/3.0.0"
{"error":"404 Not Found"}
If we change /
by %2F
the error disappears:
$ curl --header "PRIVATE-TOKEN: <your_access_token" "https://gitlab.com/api/v4/projects/carlosrivas%2Fclub/repository/tags/3.0.0"
{"name":"3.0.0","message":"","target":"1530eca79880716fca37a3aec7e869f0261b0b37","commit":{"id":"1530eca79880716fca37a3aec7e869f0261b0b37","short_id":"1530eca7","created_at":"2020-06-08T12:14:22.000+00:00","parent_ids":["915afb33394ea374da47e1a2d31efca619001276"],"title":"build: version 3.0.0 #251","message":"build: version 3.0.0 #251","author_name":"Adrian Queipo Pardo","author_email":"aqueipo@gmail.com","authored_date":"2020-06-08T12:14:22.000+00:00","committer_name":"Adrian Queipo Pardo","committer_email":"aqueipo@gmail.com","committed_date":"2020-06-08T12:14:22.000+00:00","web_url":"https://gitlab.com/carlosrivas/club/-/commit/1530eca79880716fca37a3aec7e869f0261b0b37"},"release":{"tag_name":"3.0.0","description":"## [3.0.0] - 2020-06-08\r\n### Added\r\n- Django version 3.0.5 !552\r\n- New Aforo functionlity !576\r\n- sentry-sdk 0.14.4 !577"},"protected":false}a
The documentation in gitlab says that GET /projects/:id/releases
the field id
can be the projectId (available through CI_PROJECT_ID environment variable) or the URL-encoded path of the project (available through CI_PROJECT_PATH)
Documentation list tags here
Proposed solution
The current code uses de CI_PROJECT_PATH CICD environment variable.
// release commit-and-tag
// release tag-and-commit
func commitAndTagBase(c *cli.Context, reversed bool) error {
createTagPipeline := c.Bool("create-tag-pipeline")
tagPrefix := strings.TrimSpace(c.GlobalString("tag-prefix"))
branch := c.GlobalString("ci-commit-ref-name")
project := c.GlobalString("ci-project-path")
messageTmpl := c.GlobalString("bump-commit-tmpl")
refFunc := actions.FuncOfString(c.GlobalString("ci-commit-sha"))
files := c.Args()
Option 1
Substitution of %2F
instead of /
in the url-encoded path of the project
Option 2
Make use of CI_PROJECT_ID variable
Edited by Adrian Queipo Pardo