Chrissi Grilus
Chrissi Grilus

Reputation: 1385

Missing plugins when running semantic-release in Gitlab CI

I would love to use semantic-release to manage our semantic versioning. For that I tried to integrate it into our Gitlab CI. I followed some examples and provided the necessary environment variables to push code to the repo. When semantic-release starts to run it throws the following error:

$ yarn semantic-release
yarn run v1.22.10
warning package.json: No license field
$ /Users/vision-ci/builds/dFCxNLEA/0/Christoph.Griehl/semantic-versioning/node_modules/.bin/semantic-release
[11:28:47 AM] [semantic-release] › ℹ  Running semantic-release version 17.4.3
[11:28:47 AM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/changelog"
[11:28:47 AM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/git"
[11:28:48 AM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/gitlab"
[11:28:48 AM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[11:28:48 AM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[11:28:48 AM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/changelog"
[11:28:48 AM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/git"
[11:28:48 AM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/gitlab"
[11:28:48 AM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/npm"
[11:28:48 AM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/github"
[11:28:48 AM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/github"
[11:28:48 AM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/github"
[11:28:50 AM] [semantic-release] › ✔  Run automated release from branch somebranch on repository https://gitlab-ci-token:[secure]@gitlab.wabo.run/Christoph.Griehl/semantic-versioning.git
[11:28:50 AM] [semantic-release] › ✔  Allowed to push to the Git repository
[11:28:50 AM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/changelog"
[11:28:50 AM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/changelog"
[11:28:50 AM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/git"
[11:28:50 AM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/git"
[11:28:50 AM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/gitlab"
[11:28:50 AM] [semantic-release] [@semantic-release/gitlab] › ℹ  Verify GitLab authentication (https://gitlab.wabo.run/api/v4)
[11:28:51 AM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/gitlab"
[11:28:51 AM] [semantic-release] › ℹ  No git tag version found on branch somebranch
[11:28:51 AM] [semantic-release] › ℹ  No previous release found, retrieving all commits
[11:28:51 AM] [semantic-release] › ℹ  Found 59 commits since last release
[11:28:51 AM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[11:28:51 AM] [semantic-release] › ✖  Failed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[11:28:51 AM] [semantic-release] › ✖  An error occurred while running semantic-release: Error: Cannot find module 'conventional-changelog-conventionalcommits'
Require stack:
- /Users/vision-ci/builds/[secure]/0/Christoph.Griehl/semantic-versioning/noop.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
    at resolveFileName (/Users/vision-ci/builds/[secure]/0/Christoph.Griehl/semantic-versioning/node_modules/resolve-from/index.js:29:39)
    at resolveFrom (/Users/vision-ci/builds/[secure]/0/Christoph.Griehl/semantic-versioning/node_modules/resolve-from/index.js:43:9)
    at module.exports (/Users/vision-ci/builds/[secure]/0/Christoph.Griehl/semantic-versioning/node_modules/resolve-from/index.js:46:47)
    at module.exports (/Users/vision-ci/builds/[secure]/0/Christoph.Griehl/semantic-versioning/node_modules/import-from/index.js:4:55)
    at module.exports (/Users/vision-ci/builds/[secure]/0/Christoph.Griehl/semantic-versioning/node_modules/@semantic-release/commit-analyzer/lib/load-parser-config.js:22:67)
    at analyzeCommits (/Users/vision-ci/builds/[secure]/0/Christoph.Griehl/semantic-versioning/node_modules/@semantic-release/commit-analyzer/index.js:29:24)
    at validator (/Users/vision-ci/builds/[secure]/0/Christoph.Griehl/semantic-versioning/node_modules/semantic-release/lib/plugins/normalize.js:34:30)
    at /Users/vision-ci/builds/[secure]/0/Christoph.Griehl/semantic-versioning/node_modules/semantic-release/lib/plugins/pipeline.js:37:40
    at next (/Users/vision-ci/builds/[secure]/0/Christoph.Griehl/semantic-versioning/node_modules/p-reduce/index.js:17:9) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/vision-ci/builds/[secure]/0/Christoph.Griehl/semantic-versioning/noop.js'
  ],
  pluginName: '@semantic-release/commit-analyzer'
}
Error: Cannot find module 'conventional-changelog-conventionalcommits'

As you can see it seems to load some plugins but always fails at this step. My ci.yaml looks like this:

release:
  stage: release
  tags:
    - wandelbots-web
  script:
    - yarn
    - env
    - yarn semantic-release
  except:
    refs:
      - tags
    variables:
      - $CI_COMMIT_TITLE =~ /^RELEASE:.+$/

my package.json:

  "devDependencies": {
    "@semantic-release/changelog": "^5.0.1",
    "@semantic-release/commit-analyzer": "^8.0.1",
    "@semantic-release/git": "^9.0.0",
    "@semantic-release/gitlab": "^6.1.0",
    "@semantic-release/npm": "^7.1.3",
    "@semantic-release/release-notes-generator": "^9.0.2",
    "semantic-release": "^17.4.3",
    "semantic-release-slack-bot": "^2.1.1"
  }

and my semantic-release config:

branches: ['master', 'somebranch']
ci: true
debug: true
dryRun: false
tagFormat: '${version}'

# Global plugin options (will be passed to all plugins)
preset: 'conventionalcommits'
gitlabUrl: 'https://gitlab.OURREPOURL/' # your gitlab url
slackWebhook: 'MYSLACKURL' # if you need slack notifies

# Responsible for verifying conditions necessary to proceed with the release:
# configuration is correct, authentication token are valid, etc...
verifyConditions:
  - '@semantic-release/changelog'
  - '@semantic-release/git'
  - '@semantic-release/gitlab'
  # - 'semantic-release-slack-bot'

# Responsible for determining the type of the next release (major, minor or patch).
# If multiple plugins with a analyzeCommits step are defined, the release type will be
# the highest one among plugins output.
# Look details at: https://github.com/semantic-release/commit-analyzer#configuration
analyzeCommits:
  - path: '@semantic-release/commit-analyzer'


# Responsible for generating the content of the release note.
# If multiple plugins with a generateNotes step are defined,
# the release notes will be the result of the concatenation of each plugin output.
generateNotes:
  - path: '@semantic-release/release-notes-generator'
    writerOpts:
      groupBy: 'type'
      commitGroupsSort: 'title'
      commitsSort: 'header'
    linkCompare: true
    linkReferences: true

# Responsible for preparing the release, for example creating or updating files
# such as package.json, CHANGELOG.md, documentation or compiled assets
# and pushing a commit.
prepare:
  - path: '@semantic-release/changelog'
  - path: '@semantic-release/git'
    message: 'RELEASE: ${nextRelease.version}'
    assets: ['CHANGELOG.md']

# Responsible for publishing the release.
publish:
  - path: '@semantic-release/gitlab'

success:
  # - path: 'semantic-release-slack-bot'
  #   notifyOnSuccess: true
  #   markdownReleaseNotes: false

fail:
  # - path: 'semantic-release-slack-bot'
  #   notifyOnFail: true

I would be really grateful if someone could push me into the right direction. I have tried 2 different physical gitlab-runners now, both MAC and the error is the same.

Upvotes: 5

Views: 7234

Answers (1)

L. Lenz
L. Lenz

Reputation: 121

You defined 'conventionalcommits' as preset for the commit message analyzer. In order to use this preset you have to include it into your (dev)dependencies. This is at least the error aaccording to the npm error message: "Cannot find module 'conventional-changelog-conventionalcommits'.

Just add it to your (dev)dependencies:

yarn add -D conventional-changelog-conventionalcommits

or

npm i --save-dev conventional-changelog-conventionalcommits

should solve your problem.

Here is the repo-link for the package.

https://github.com/conventional-changelog/conventional-changelog

I hope this will help to solve your problem!

Upvotes: 5

Related Questions