Gitlab CI/CD Variables for semantic-release and nexus

380 views Asked by At

I have a vite project and the repository is hosted in gitlab. Now I'd like to use semantic-release (v20.0.0) in order to handle the versioning and the release to the nexus-npm server.

The .yml file release path is this:

release:
  stage: release
  script:
    - npm ci
    - npm run build
    - npm run semantic-release
  only:
    - developer
    - master
  when: manual

As far as the semantic-release docu tells I need these ci/cd variables:

GL_TOKEN or GITLAB_TOKEN    //A GitLab personal access token. (I added a new pat add my user settings/access token)
NPM_TOKEN                   //nexus doesn't support npm_token authentication

The nexus-server requires authentication with username and password. So I have added npm_username and npm_password variables:

NPM_PASSWORD    //nexus password
NPM_USERNAME    //nexus username
NPM_EMAIL       //nexus email

The release-pipeline throws this error:

 An error occurred while running semantic-release: Error: Command failed with exit code 128: git ls-remote --heads https://company-gitlab.company.de/user/project-name.git
remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password.

It seems, that the GL_TOKEN does not work, or other variables are required. Does anyone have an idea?

Here is the configuration of the.releaserc:

{
  "branches": [
    "+([0-9])?(.{+([0-9]),x}).x",
    "master",
    {
      "name": "developer",
      "prerelease": "alpha"
    }
  ],
  "plugins": [
   "@semantic-release/commit-analyzer",
   "@semantic-release/release-notes-generator",
   [
     "@semantic-release/npm",
     {
       "pkgRoot": "./dist"
     }
   ],
   [
     "@semantic-release/gitlab",
     {
       "gitlabUrl": "https://company.gitlab.com"
     }
   ]
 ]
}
0

There are 0 answers