Deleted tags are present in Gitlab-CI
Asked Answered
C

3

8

I'm using semantic-release for versioning. Whenever I push something to my branch, the CI (Gitlab) executes the semantic-release. My problem is that I pushed to my git branch, semantic-release created a release and created the tag (e.g. 1.0.0). Finally, I figured out that I missed something important to this commit. So I deleted the tag in Gitlab (Repository > Tags, e.g. https://gitlab.com/user/project/-/tags) and finally pushed my commit again. But now, semantic-release tells me that the tag already exist but Gitlab doesn't show any tags anymore (I deleted all tags). Now I decided to add the following line to my CI:

git show-ref --tags -d

This shows me all the tags I deleted in Gitlab already, but it seems that they're present in my CI. So I'm confused what's going on here... Any ideas? Do I need something like "syncing tags" in my CI?

Calender answered 4/2, 2021 at 13:53 Comment(0)
R
4

This behaviour is caused by the runners dirty cache. In .gitlab-ci.yml you should declare git strategy as clone instead of fetch as follows:

ajob:
  variables:
    GIT_STRATEGY: clone

Here are some discussions on this specific behaviour:

Missing tags on repo cloned by GitLab CI

Removed git tag detected on gitlab remote CI but not on local repository

Rolfe answered 22/3, 2023 at 7:19 Comment(0)
K
4

To solve this problem I use this workaround to sync from origin all tag :

- git tag --delete $(git tag) # delete all local tags  
- git fetch --all
Krefeld answered 31/8, 2021 at 11:8 Comment(0)
R
4

This behaviour is caused by the runners dirty cache. In .gitlab-ci.yml you should declare git strategy as clone instead of fetch as follows:

ajob:
  variables:
    GIT_STRATEGY: clone

Here are some discussions on this specific behaviour:

Missing tags on repo cloned by GitLab CI

Removed git tag detected on gitlab remote CI but not on local repository

Rolfe answered 22/3, 2023 at 7:19 Comment(0)
M
0

Git is a distributed source control repository, which means that any local repositories configured to track a remote repository (which can be Gitlab, Github, another personal computer, etc.). Each repository acts independently, but can push or pull changes between them.

For example, when you change files locally and commit them, they only exist in your repository until you push them to a remote (usually this is Github, Gitlab, etc.). Then, the changes will be locally for you and on Gitlab. If someone else then does a git pull from the Gitlab remote, the changes will be in their local environment too.

Similarly, deleting the tags in Gitlab only deletes them from that repository, but not anywhere else. If a tag has been deleted on a remote and you wise to delete it locally, the most direct way is to git tag --delete|-d tag1 tag2 ..., but you'd have to know what the tags are.

If you're running git version 2.17 or higher, you can pass a flag to git fetch that will prune tags like it can with branches: git fetch --prune --prune-tags. The --prune option removes any local branches that don't exist in the remote, and --prune-tags does the same for tags.

Here's some useful SO questions that are related:

Remove local git tags that are no longer on the remote repository

In git, how do I sync my tags against a remote server?

Magnificence answered 15/2, 2021 at 20:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.