-1

I am trying to push the tag in tagging stage of pipeline, I have a logic to form a tag and push it back to repo. Now to push the tag, I've created project access token and have below in my gitlab yml. The output is with "set -x"

$ git push "${TEST_TAG}" "${CI_REPOSITORY_URL}"
++ git push v1.0.0 https://gitlab-ci-token:[MASKED]@gitlab.demo.com/demouser/demoproject.git
error: src refspec https://gitlab-ci-token does not match any

queries:

  1. this is because I haven't set the variable with access token value in gitlab yml? also if I do so, doesn't it expose the token?
  2. what am I missing here?

Also, what would be the best practice as of 2022 to do so. Thanks.

SD.
  • 1,432
  • 22
  • 38
  • Do you have an example workflow you’re working off of? In my experience tag stages are used to test or deploy manually created tags, which are either pushed by users or created through the api or interface. Generally you can’t push to the repo from within CICD. But maybe you’re aware of a pattern I’m not familiar with. – Michael Delgado Jun 16 '22 at 16:46
  • @MichaelDelgado - this works with `git push https://oauth2:${PROJECT_TOKEN}@${GITLAB_PROJECT_URL}.git "${NEW_TAG}" -o ci.skip` – SD. Jun 20 '22 at 20:11

1 Answers1

1
git push "${TEST_TAG}" "${CI_REPOSITORY_URL}"

These arguments are in the wrong order. The URL (or <remote>) argument must be the first positional argument. The remaining arguments are refspecs. The simplest form of a refspec is a branch or tag name: Git will take that and find the full spelling of that name.

The second simplest form is to put a branch or tag name on the left side of a colon, and another branch or tag name on the right side of a colon. The left side is then the source ref and the right side is the destination. Your refspec was:

https://gitlab-ci-token

so the source part was https. Git tries to find a branch or tag whose name is https. There isn't one, hence the error message:

error: src refspec https://gitlab-ci-token does not match any

(not a very good error message, in my opinion, but it's what you get).

torek
  • 448,244
  • 59
  • 642
  • 775