语义发布不接受 gitlab 私有存储库上的 GITLAB_TOKEN

Semantic release not accepting GITLAB_TOKEN on gitlab private repository

这是错误日志消息:

[3:40:55 PM] [semantic-release] › ✖ The command "git push --dry-run --no-verify https://gitlab-ci-token:[secure]@[repository-url].git HEAD:main" failed with the error message remote: You are not allowed to upload code. fatal: unable to access 'https://gitlab-ci-token:[secure]@[repository-url]/': The requested URL returned error: 403.

我在存储库设置中设置了一个 GITLAB_TOKEN 并具有所有必要的权限,但它似乎甚至没有被使用:

这是我的 .releaserc.json 配置:

{
  "branches": ["main", { "name": "beta", "prerelease": true }],
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    "@semantic-release/changelog",
    "@semantic-release/npm",
    "@semantic-release/gitlab",
    [
      "@semantic-release/git",
      {
        "assets": ["package.json", "package-lock.json", "CHANGELOG.md"],
        "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ]
  ]
}

这是我的 .gitlab-ci.yml 配置:

# NodeJs image
image: node:16

# STAGES
stages:
  - checks
  - build
  - release

# SETUP
before_script:
  - node -v
  - npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
  - npm ci --cache .npm --prefer-offline

# JOBS
lint:
  stage: checks
  script:
    - npm run lint

test:
  stage: checks
  script:
    - npm run test:ci

build:
  stage: build
  script:
    - npm run build

release:
  stage: release
  only:
    - main
  script:
    - npx semantic-release

这是我正在使用的语义发布依赖项及其版本:

"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@semantic-release/gitlab": "^7.0.4",
"@semantic-release": "^19.0.2",

GITLAB_TOKEN 作为维护者是存储库的成员(就像语义发布工作的其他存储库一样):

有什么建议吗?

所以最后的问题是我必须在 Settings > CI/CD > Variables

中添加创建的 GITLAB_TOKEN 访问令牌