Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No new release with message "object not found" #11

Open
Melkor333 opened this issue Dec 31, 2024 · 4 comments
Open

No new release with message "object not found" #11

Melkor333 opened this issue Dec 31, 2024 · 4 comments

Comments

@Melkor333
Copy link

Melkor333 commented Dec 31, 2024

I have the following configuration in my .gitlab-ci.yml which AFAIU should use the $CI_JOB_TOKEN:

stages:
  - release
  - package
  - publish

release:
  stage: release
  variables:
    GIT_STRATEGY: clone
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
  image:
    name: "registry.gitlab.com/go-semantic-release/semantic-release:latest"
    entrypoint: [""]
  stage: release
  script:
    - semantic-release
...

But all I get is the following output:

$ semantic-release
[go-semantic-release]: version: 2.31.0
[go-semantic-release]: trying to prefetch plugins...
[go-semantic-release]: all plugins were prefetched!
[go-semantic-release]: ci-condition plugin: GitLab [email protected]
[go-semantic-release]: provider plugin: [email protected]
[go-semantic-release]: getting default branch...
[go-semantic-release]: found default branch: main
[go-semantic-release]: repo is private
[go-semantic-release]: found current branch: main
[go-semantic-release]: found current sha: 8c97cab19345528233b1552e29a2e478e1664059
[go-semantic-release]: running CI condition...
[go-semantic-release]: getting latest release...
[go-semantic-release]: found version: 1.0.0
[go-semantic-release]: getting commits...
[go-semantic-release]: object not found
[go-semantic-release]: stopping plugins...
Cleaning up project directory and file based variables 00:01
ERROR: Job failed: exit code 1

I pushed 2 commits, one called feat: ... directly to the main branch so it should generate a new version. (it
Running the same thing locally works (but isn't using provider-gitlab for obvious reasons).
I tried --provider git which failed later on so I assume it's the gitlab provider causing issues?

I also had a previous commit without a change right after the manually created tag v1.0.0 which was only ci: and thus didn't create any change - which confusingly worked!:

$ semantic-release --provider gitlab --provider-opt log_order=ctime
[go-semantic-release]: version: 2.31.0
[go-semantic-release]: trying to prefetch plugins...
[go-semantic-release]: all plugins were prefetched!
[go-semantic-release]: ci-condition plugin: GitLab [email protected]
[go-semantic-release]: provider plugin: [email protected]
[go-semantic-release]: getting default branch...
[go-semantic-release]: found default branch: main
[go-semantic-release]: repo is private
[go-semantic-release]: found current branch: main
[go-semantic-release]: found current sha: 8fe10a45d0c027c7d3b187e800cdd50a814b1910
[go-semantic-release]: running CI condition...
[go-semantic-release]: getting latest release...
[go-semantic-release]: found version: 1.0.0
[go-semantic-release]: getting commits...
[go-semantic-release]: analyzing commits...
[go-semantic-release]: commit-analyzer plugin: [email protected]
[go-semantic-release]: calculating new version...
[go-semantic-release]: no change
[go-semantic-release]: stopping plugins...

I'm not sure how to debug this any further. I can imagine it to work with a manually crafted GITLAB_TOKEN, but using the CI_JOB_TOKEN would be much more feasible, especially now that any PAT expires after a year, which would be a big pain for the many repositories we maintain in the company. Therefore I'd like to debug this properly instead of having to create manual tokens everywhere (if that's even the issue).

@guisea
Copy link

guisea commented Jan 1, 2025

Hi,

I just leave a comment here. Not sure this is the same issue but I maintain the gitea provider for go-semantic-release. I found when encountering an error approximately at this same point in the flow that the actual cause was an unknown author/committer.

This meant that the user for the commit was empty.

I put some extra messaging around this so my provider tells you the exact email it encountered this fault with. See

			if commit.Author == nil {
				return nil, fmt.Errorf("gitea: author is not found. Check email [%s] is assigned to user",
					commit.RepoCommit.Author.Email)
			}

			if commit.Committer == nil {
				return nil, fmt.Errorf("gitea: committer is not found. Check email [%s] is assigned to user",
					commit.RepoCommit.Committer.Email)
			}

From there you can create a user in Gitlab which has that email assigned to allow the API to return a matching user object.

You might see this more if you are importing/cloning repositories from outside your organisation example Github.

Gitea is a different system altogether I know but the behavior seems the same so it might be relevant.

@Melkor333
Copy link
Author

Hi,

I just leave a comment here. Not sure this is the same issue but I maintain the gitea provider for go-semantic-release. I found when encountering an error approximately at this same point in the flow that the actual cause was an unknown author/committer.

This meant that the user for the commit was empty.

I put some extra messaging around this so my provider tells you the exact email it encountered this fault with. See

			if commit.Author == nil {
				return nil, fmt.Errorf("gitea: author is not found. Check email [%s] is assigned to user",
					commit.RepoCommit.Author.Email)
			}

			if commit.Committer == nil {
				return nil, fmt.Errorf("gitea: committer is not found. Check email [%s] is assigned to user",
					commit.RepoCommit.Committer.Email)
			}

From there you can create a user in Gitlab which has that email assigned to allow the API to return a matching user object.

You might see this more if you are importing/cloning repositories from outside your organisation example Github.

Gitea is a different system altogether I know but the behavior seems the same so it might be relevant.

Thanks a lot for taking your time and giving some feedback!
OK yeah I get that I have actually made an automated commit once, but in a different branch and I've also removed that branch now and the error still happens.

What I also don't get is why there needs to be a matching user in Gitlab? From what I see, given that I "make it" use the CI_JOB_TOKEN, the following gets executed and AFAIU this means it gets author/committer from the git provider, (following snippet in the file):

func (repo *GitLabRepository) GetReleases(rawRe string) ([]*semrel.Release, error) {
	if repo.useJobToken {
		return repo.localRepo.GetReleases(rawRe)
	}

So I don't get why it fails when each commt HAS an author and a committer, just not necessarily someone existing in gitlab?

I've even tried to reproduce it in a container locally and it just works... (I set export CI_JOB_TOKEN=ACCESS_TOKEN_WITH_WAY_TOO_MANY_PERMISSIONS though, so maybe it's a permission issue with the CI_JOB_TOKEN?)

@Melkor333
Copy link
Author

Melkor333 commented Jan 3, 2025

FWIW I just retried with a personal access token and immediately works. So definitely only an issue when using the JOB_TOKEN!

@guisea
Copy link

guisea commented Jan 4, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants