semantic-release / gitlab

:fox_face: semantic-release plugin to publish a GitLab release
MIT License
284 stars 79 forks source link

Failed step "publish" - An error occurred while making a request to the GitLab release API: HTTPError: Response code 403 (Forbidden) #781

Closed MartinMystikJonas closed 4 weeks ago

MartinMystikJonas commented 1 month ago

Whet trying to run semantic release I get this error:

[1:00:30 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/gitlab"
[1:00:30 PM] [semantic-release] [@semantic-release/gitlab] › ✘  An error occurred while making a request to the GitLab release API:
HTTPError: Response code 403 (Forbidden)
    at Request.<anonymous> (file:///builds/git/metis-appfw/node_modules/got/dist/source/as-promise/index.js:92:42)
    at Object.onceWrapper (node:events:634:26)
    at Request.emit (node:events:531:35)
    at Request._onResponseBase (file:///builds/git/metis-appfw/node_modules/got/dist/source/core/index.js:603:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Request._onResponse (file:///builds/git/metis-appfw/node_modules/got/dist/source/core/index.js:643:13)

Release pushes commit upgrading version to repository but now version is not created in package registry.

I have set up GITLAB_TOKEN with these permissions: read_api, read_repository, write_repository, read_registry, write_registry. Our GITLAB_TOKEN is still valid (any we can see it is used to push)

It worked with same configuration few months ago when I last time make release with this project. I changed nothing since then.

Full log:

> semantic-release
[1:00:21 PM] [semantic-release] › ℹ  Running semantic-release version 24.1.2
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/gitlab"
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/npm"
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/git"
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/npm"
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/git"
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/gitlab"
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/npm"
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/npm"
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/gitlab"
[1:00:21 PM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/gitlab"
[1:00:25 PM] [semantic-release] › ✔  Run automated release from branch v2 on repository [https://gitlab-ci-token:[secure]@git.lwg.cz/git/metis-appfw.git](https://gitlab-ci-token:%5Bsecure%5D@git.lwg.cz/git/metis-appfw.git)
[1:00:25 PM] [semantic-release] › ✔  Allowed to push to the Git repository
[1:00:25 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/gitlab"
[1:00:25 PM] [semantic-release] [@semantic-release/gitlab] › ℹ  Verify GitLab authentication (https://git.lwg.cz/api/v4)
[1:00:25 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/gitlab"
[1:00:25 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/npm"
[1:00:25 PM] [semantic-release] [@semantic-release/npm] › ℹ  Verify authentication for registry https://git.lwg.cz/api/v4/projects/34/packages/npm/
[1:00:25 PM] [semantic-release] [@semantic-release/npm] › ℹ  Reading npm config from /builds/git/metis-appfw/.npmrc
[1:00:25 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/npm"
[1:00:25 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/git"
[1:00:25 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/git"
[1:00:25 PM] [semantic-release] › ℹ  Found git tag v2.0.9 associated with version 2.0.9 on branch v2
[1:00:25 PM] [semantic-release] › ℹ  Found 2 commits since last release
[1:00:25 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[1:00:25 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: Merge remote-tracking branch 'origin/v2' into v2
[1:00:25 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The commit should not trigger a release
[1:00:25 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: npm: Testing npm release
[1:00:25 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The release type for the commit is patch
[1:00:25 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analysis of 2 commits complete: patch release
[1:00:25 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[1:00:25 PM] [semantic-release] › ℹ  The next release version is 2.0.10
[1:00:25 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[1:00:25 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[1:00:25 PM] [semantic-release] › ℹ  Start step "prepare" of plugin "@semantic-release/npm"
[1:00:25 PM] [semantic-release] [@semantic-release/npm] › ℹ  Write version 2.0.10 to package.json in /builds/git/metis-appfw
v2.0.10
[1:00:26 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/npm"
[1:00:26 PM] [semantic-release] › ℹ  Start step "prepare" of plugin "@semantic-release/git"
[1:00:26 PM] [semantic-release] [@semantic-release/git] › ℹ  Found 1 file(s) to commit
[1:00:27 PM] [semantic-release] [@semantic-release/git] › ℹ  Prepared Git release: v2.0.10
[1:00:27 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/git"
[1:00:27 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[1:00:27 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[1:00:30 PM] [semantic-release] › ✔  Created tag v2.0.10
[1:00:30 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/gitlab"
[1:00:30 PM] [semantic-release] [@semantic-release/gitlab] › ✘  An error occurred while making a request to the GitLab release API:
HTTPError: Response code 403 (Forbidden)
    at Request.<anonymous> (file:///builds/git/metis-appfw/node_modules/got/dist/source/as-promise/index.js:92:42)
    at Object.onceWrapper (node:events:634:26)
    at Request.emit (node:events:531:35)
    at Request._onResponseBase (file:///builds/git/metis-appfw/node_modules/got/dist/source/core/index.js:603:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Request._onResponse (file:///builds/git/metis-appfw/node_modules/got/dist/source/core/index.js:643:13) {
  input: undefined,
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 1729162830600,
    socket: 1729162830601,
    lookup: 1729162830601,
    connect: 1729162830601,
    secureConnect: 1729162830601,
    upload: 172916[283](https://git.lwg.cz/git/metis-appfw/-/jobs/60141#L283)0601,
    response: 1729162830662,
    end: 1729162830663,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 1,
      dns: 0,
      tcp: 0,
      tls: 0,
      request: 0,
      firstByte: 61,
      download: 1,
      total: 63
    }
  },
  options: {
    request: undefined,
    agent: { http: undefined, https: undefined, http2: undefined },
    h2session: undefined,
    decompress: true,
    timeout: {
      connect: undefined,
      lookup: undefined,
      read: undefined,
      request: undefined,
      response: undefined,
      secureConnect: undefined,
      send: undefined,
      socket: undefined
    },
    prefixUrl: '',
    body: '{"tag_name":"v2.0.10","description":"## [2.0.10](https://git.lwg.cz/git/metis-appfw/compare/v2.0.9...v2.0.10) (2024-10-17)\\n\\n\\n\\n","assets":{"links":[]}}',
    form: undefined,
    json: undefined,
    cookieJar: undefined,
    ignoreInvalidCookies: false,
    searchParams: undefined,
    dnsLookup: undefined,
    dnsCache: undefined,
    context: {},
    hooks: {
      init: [],
      beforeRequest: [],
      beforeError: [ [Function (anonymous)] ],
      beforeRedirect: [],
      beforeRetry: [],
      afterResponse: []
    },
    followRedirect: true,
    maxRedirects: 10,
    cache: undefined,
    throwHttpErrors: true,
    username: '',
    password: '',
    http2: false,
    allowGetBody: false,
    headers: {
      'user-agent': 'got (https://github.com/sindresorhus/got)',
      'private-token': '[secure]',
      'content-type': 'application/json',
      'content-length': '154',
      'accept-encoding': 'gzip, deflate, br'
    },
    methodRewriting: false,
    dnsLookupIpVersion: undefined,
    parseJson: [Function: parse],
    stringifyJson: [Function: stringify],
    retry: {
      limit: 2,
      methods: [ 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE' ],
      statusCodes: [
        408, 413, 429, 500,
        502, 503, 504, 521,
        522, 524
      ],
      errorCodes: [
        'ETIMEDOUT',
        'ECONNRESET',
        'EADDRINUSE',
        'ECONNREFUSED',
        'EPIPE',
        'ENOTFOUND',
        'ENETUNREACH',
        'EAI_AGAIN'
      ],
      maxRetryAfter: undefined,
      calculateDelay: [Function: calculateDelay],
      backoffLimit: Infinity,
      noise: 100
    },
    localAddress: undefined,
    method: 'POST',
    createConnection: undefined,
    cacheOptions: {
      shared: undefined,
      cacheHeuristic: undefined,
      immutableMinTimeToLive: undefined,
      ignoreCargoCult: undefined
    },
    https: {
      alpnProtocols: undefined,
      rejectUnauthorized: undefined,
      checkServerIdentity: undefined,
      certificateAuthority: undefined,
      key: undefined,
      certificate: undefined,
      passphrase: undefined,
      pfx: undefined,
      ciphers: undefined,
      honorCipherOrder: undefined,
      minVersion: undefined,
      maxVersion: undefined,
      signatureAlgorithms: undefined,
      tlsSessionLifetime: undefined,
      dhparam: undefined,
      ecdhCurve: undefined,
      certificateRevocationLists: undefined
    },
    encoding: undefined,
    resolveBodyOnly: false,
    isStream: false,
    responseType: 'text',
    url: URL {
      href: 'https://git.lwg.cz/api/v4/projects/git%2Fmetis-appfw/releases',
      origin: 'https://git.lwg.cz',
      protocol: 'https:',
      username: '',
      password: '',
      host: 'git.lwg.cz',
      hostname: 'git.lwg.cz',
      port: '',
      pathname: '/api/v4/projects/git%2Fmetis-appfw/releases',
      search: '',
      searchParams: URLSearchParams {},
      hash: ''
    },
    pagination: {
      transform: [Function: transform],
      paginate: [Function: paginate],
      filter: [Function: filter],
      shouldContinue: [Function: shouldContinue],
      countLimit: Infinity,
      backoff: 0,
      requestLimit: 10000,
      stackAllItems: false
    },
    setHost: true,
    maxHeaderSize: undefined,
    signal: undefined,
    enableUnixSockets: false
  },
  [cause]: {}
}
[1:00:30 PM] [semantic-release] › ✘  Failed step "publish" of plugin "@semantic-release/gitlab"
[1:00:30 PM] [semantic-release] › ✘  An error occurred while running semantic-release: HTTPError: Response code 403 (Forbidden)
    at Request.<anonymous> (file:///builds/git/metis-appfw/node_modules/got/dist/source/as-promise/index.js:92:42)
    at Object.onceWrapper (node:events:634:26)
    at Request.emit (node:events:531:35)
    at Request._onResponseBase (file:///builds/git/metis-appfw/node_modules/got/dist/source/core/index.js:603:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Request._onResponse (file:///builds/git/metis-appfw/node_modules/got/dist/source/core/index.js:643:13) {
  input: undefined,
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 17[291](https://git.lwg.cz/git/metis-appfw/-/jobs/60141#L291)62830600,
    socket: 1729162830601,
    lookup: 1729162830601,
    connect: 1729162830601,
    secureConnect: 1729162830601,
    upload: 1729162830601,
    response: 1729162830662,
    end: 1729162830663,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 1,
      dns: 0,
      tcp: 0,
      tls: 0,
      request: 0,
      firstByte: 61,
      download: 1,
      total: 63
    }
  },
  options: {
    request: undefined,
    agent: { http: undefined, https: undefined, http2: undefined },
    h2session: undefined,
    decompress: true,
    timeout: {
      connect: undefined,
      lookup: undefined,
      read: undefined,
      request: undefined,
      response: undefined,
      secureConnect: undefined,
      send: undefined,
      socket: undefined
    },
    prefixUrl: '',
    body: '{"tag_name":"v2.0.10","description":"## [2.0.10](https://git.lwg.cz/git/metis-appfw/compare/v2.0.9...v2.0.10) (2024-10-17)\\n\\n\\n\\n","assets":{"links":[]}}',
    form: undefined,
    json: undefined,
    cookieJar: undefined,
    ignoreInvalidCookies: false,
    searchParams: undefined,
    dnsLookup: undefined,
    dnsCache: undefined,
    context: {},
    hooks: {
      init: [],
      beforeRequest: [],
      beforeError: [ [Function (anonymous)] ],
      beforeRedirect: [],
      beforeRetry: [],
      afterResponse: []
    },
    followRedirect: true,
    maxRedirects: 10,
    cache: undefined,
    throwHttpErrors: true,
    username: '',
    password: '',
    http2: false,
    allowGetBody: false,
    headers: {
      'user-agent': 'got (https://github.com/sindresorhus/got)',
      'private-token': '[secure]',
      'content-type': 'application/json',
      'content-length': '154',
      'accept-encoding': 'gzip, deflate, br'
    },
    methodRewriting: false,
    dnsLookupIpVersion: undefined,
    parseJson: [Function: parse],
    stringifyJson: [Function: stringify],
    retry: {
      limit: 2,
      methods: [ 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE' ],
      statusCodes: [
        408, 413, 429, 500,
        502, 503, 504, 521,
        522, 524
      ],
      errorCodes: [
        'ETIMEDOUT',
        'ECONNRESET',
        'EADDRINUSE',
        'ECONNREFUSED',
        'EPIPE',
        'ENOTFOUND',
        'ENETUNREACH',
        'EAI_AGAIN'
      ],
      maxRetryAfter: undefined,
      calculateDelay: [Function: calculateDelay],
      backoffLimit: Infinity,
      noise: 100
    },
    localAddress: undefined,
    method: 'POST',
    createConnection: undefined,
    cacheOptions: {
      shared: undefined,
      cacheHeuristic: undefined,
      immutableMinTimeToLive: undefined,
      ignoreCargoCult: undefined
    },
    https: {
      alpnProtocols: undefined,
      rejectUnauthorized: undefined,
      checkServerIdentity: undefined,
      certificateAuthority: undefined,
      key: undefined,
      certificate: undefined,
      passphrase: undefined,
      pfx: undefined,
      ciphers: undefined,
      honorCipherOrder: undefined,
      minVersion: undefined,
      maxVersion: undefined,
      signatureAlgorithms: undefined,
      tlsSessionLifetime: undefined,
      dhparam: undefined,
      ecdhCurve: undefined,
      certificateRevocationLists: undefined
    },
    encoding: undefined,
    resolveBodyOnly: false,
    isStream: false,
    responseType: 'text',
    url: URL {
      href: 'https://git.lwg.cz/api/v4/projects/git%2Fmetis-appfw/releases',
      origin: 'https://git.lwg.cz',
      protocol: 'https:',
      username: '',
      password: '',
      host: 'git.lwg.cz',
      hostname: 'git.lwg.cz',
      port: '',
      pathname: '/api/v4/projects/git%2Fmetis-appfw/releases',
      search: '',
      searchParams: URLSearchParams {},
      hash: ''
    },
    pagination: {
      transform: [Function: transform],
      paginate: [Function: paginate],
      filter: [Function: filter],
      shouldContinue: [Function: shouldContinue],
      countLimit: Infinity,
      backoff: 0,
      requestLimit: 10000,
      stackAllItems: false
    },
    setHost: true,
    maxHeaderSize: undefined,
    signal: undefined,
    enableUnixSockets: false
  },
  pluginName: '@semantic-release/gitlab',
  [cause]: {}
}
HTTPError: Response code 403 (Forbidden)
    at Request.<anonymous> (file:///builds/git/metis-appfw/node_modules/got/dist/source/as-promise/index.js:92:42)
    at Object.onceWrapper (node:events:634:26)
    at Request.emit (node:events:531:35)
    at Request._onResponseBase (file:///builds/git/metis-appfw/node_modules/got/dist/source/core/index.js:603:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Request._onResponse (file:///builds/git/metis-appfw/node_modules/got/dist/source/core/index.js:643:13) {
  input: undefined,
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 17291628[306](https://git.lwg.cz/git/metis-appfw/-/jobs/60141#L306)00,
    socket: 1729162830601,
    lookup: 1729162830601,
    connect: 1729162830601,
    secureConnect: 1729162830601,
    upload: 1729162830601,
    response: 1729162830662,
    end: 1729162830663,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 1,
      dns: 0,
      tcp: 0,
      tls: 0,
      request: 0,
      firstByte: 61,
      download: 1,
      total: 63
    }
  },
  options: {
    request: undefined,
    agent: { http: undefined, https: undefined, http2: undefined },
    h2session: undefined,
    decompress: true,
    timeout: {
      connect: undefined,
      lookup: undefined,
      read: undefined,
      request: undefined,
      response: undefined,
      secureConnect: undefined,
      send: undefined,
      socket: undefined
    },
    prefixUrl: '',
    body: '{"tag_name":"v2.0.10","description":"## [2.0.10](https://git.lwg.cz/git/metis-appfw/compare/v2.0.9...v2.0.10) (2024-10-17)\\n\\n\\n\\n","assets":{"links":[]}}',
    form: undefined,
    json: undefined,
    cookieJar: undefined,
    ignoreInvalidCookies: false,
    searchParams: undefined,
    dnsLookup: undefined,
    dnsCache: undefined,
    context: {},
    hooks: {
      init: [],
      beforeRequest: [],
      beforeError: [ [Function (anonymous)] ],
      beforeRedirect: [],
      beforeRetry: [],
      afterResponse: []
    },
    followRedirect: true,
    maxRedirects: 10,
    cache: undefined,
    throwHttpErrors: true,
    username: '',
    password: '',
    http2: false,
    allowGetBody: false,
    headers: {
      'user-agent': 'got (https://github.com/sindresorhus/got)',
      'private-token': '[secure]',
      'content-type': 'application/json',
      'content-length': '154',
      'accept-encoding': 'gzip, deflate, br'
    },
    methodRewriting: false,
    dnsLookupIpVersion: undefined,
    parseJson: [Function: parse],
    stringifyJson: [Function: stringify],
    retry: {
      limit: 2,
      methods: [ 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE' ],
      statusCodes: [
        408, 413, 429, 500,
        502, 503, 504, 521,
        522, 524
      ],
      errorCodes: [
        'ETIMEDOUT',
        'ECONNRESET',
        'EADDRINUSE',
        'ECONNREFUSED',
        'EPIPE',
        'ENOTFOUND',
        'ENETUNREACH',
        'EAI_AGAIN'
      ],
      maxRetryAfter: undefined,
      calculateDelay: [Function: calculateDelay],
      backoffLimit: Infinity,
      noise: 100
    },
    localAddress: undefined,
    method: 'POST',
    createConnection: undefined,
    cacheOptions: {
      shared: undefined,
      cacheHeuristic: undefined,
      immutableMinTimeToLive: undefined,
      ignoreCargoCult: undefined
    },
    https: {
      alpnProtocols: undefined,
      rejectUnauthorized: undefined,
      checkServerIdentity: undefined,
      certificateAuthority: undefined,
      key: undefined,
      certificate: undefined,
      passphrase: undefined,
      pfx: undefined,
      ciphers: undefined,
      honorCipherOrder: undefined,
      minVersion: undefined,
      maxVersion: undefined,
      signatureAlgorithms: undefined,
      tlsSessionLifetime: undefined,
      dhparam: undefined,
      ecdhCurve: undefined,
      certificateRevocationLists: undefined
    },
    encoding: undefined,
    resolveBodyOnly: false,
    isStream: false,
    responseType: 'text',
    url: URL {
      href: 'https://git.lwg.cz/api/v4/projects/git%2Fmetis-appfw/releases',
      origin: 'https://git.lwg.cz'/,
      protocol: 'https:',
      username: '',
      password: '',
      host: 'git.lwg.cz',
      hostname: 'git.lwg.cz',
      port: '',
      pathname: '/api/v4/projects/git%2Fmetis-appfw/releases',
      search: '',
      searchParams: URLSearchParams {},
      hash: ''
    },
    pagination: {
      transform: [Function: transform],
      paginate: [Function: paginate],
      filter: [Function: filter],
      shouldContinue: [Function: shouldContinue],
      countLimit: Infinity,
      backoff: 0,
      requestLimit: 10000,
      stackAllItems: false
    },
    setHost: true,
    maxHeaderSize: undefined,
    signal: undefined,
    enableUnixSockets: false
  },
  pluginName: '@semantic-release/gitlab',
  [cause]: {}
MartinMystikJonas commented 4 weeks ago

Ok my mistake i should recheck docs. Now GITLAB_TOKEN requires full api access. Only read_api, read_repository, write_repository, read_registry, write_registry is no longer enough.