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

Releasing with Gitlab CI_JOB_TOKEN #1049

Open
Z01d-b3rg opened this issue Oct 20, 2023 · 2 comments
Open

Releasing with Gitlab CI_JOB_TOKEN #1049

Z01d-b3rg opened this issue Oct 20, 2023 · 2 comments

Comments

@Z01d-b3rg
Copy link

I'm trying to release on Gitlab using only the CI_JOB_TOKEN. Since the token does not have the permission to push to the repository, I disabled the git.push option. I do not want to create a commit, only a new tag.

A new tag can be created using the releases API, but the release-it request doesn't set the ref field, which is required when creating a release for a non-existing tag_name. The error message is:

HTTPError: Response code 422 (Unprocessable Entity)

Is there any configuration option/ hook I am missing to set this? I could fall back to using a project/ group access token but would prefer not to.

Config:

 gitlab: {
    skipChecks: true,
    tokenHeader: 'JOB-TOKEN',
    release: true,
    releaseName: 'Release ${version}',
    releaseNotes: null,
    milestones: [],
    tokenRef: 'CI_JOB_TOKEN',
    certificateAuthorityFile: null,
    assets: null,
    origin: null
  },
  git: {
    push: false,
    requireCleanWorkingDir: false,
    commit: false,
    changelog: 'git log --pretty=format:"* %s (%h)" ${from}...${to}',
    requireBranch: false,
    requireUpstream: true,
    requireCommits: false,
    requireCommitsFail: true,
    commitsPath: '',
    addUntrackedFiles: false,
    commitMessage: 'Release ${version}',
    commitArgs: [],
    tag: true,
    tagExclude: null,
    tagName: null,
    tagMatch: null,
    getLatestTagFromAllRefs: false,
    tagAnnotation: 'Release ${version}',
    tagArgs: [],
    pushArgs: [ '--follow-tags' ],
    pushRepo: ''
  },
  [...]

Output:

[...]
RELEASE-IT:GITLAB 75: {
  url: 'https://gitlab.com/api/v4/projects/$id/releases',
  json: {
    name: 'Release 2023.10.20',
    tag_name: '2023.10.20.0',
    description: '# [](https://gitlab.com/$project_path/compare/2023.10.18.0...null) (2023-10-20)\n' +
      '\n' +
      '\n' +
      '### Features\n' 
  }
}
RELEASE-IT:GITLAB 75: HTTPError: Response code 422 (Unprocessable Entity)
[...]
@webpro
Copy link
Collaborator

webpro commented Oct 24, 2023

I don't have much experience with GitLab, but I guess the tag must be present in order to create a tag on the remote. Which needs to be pushed first? This is how it works with GitHub: a tag must exist on the remote to create a release.

@Z01d-b3rg
Copy link
Author

The tag can be created alongside the release if a ref is passed along. It doesn't have to exist beforehand.

From the documentation:

If a tag specified in tag_name doesn’t exist, the release is created from ref and tagged with tag_name. It can be a commit SHA, another tag name, or a branch name.

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