semantic-release: Script does not find the latest release when run in Jenkins (resolved)

Current behavior

When fetching the latest release by tag from Github, semantic-release keeps finding the v1.0.0 tag, even though there are later releases (all made by semantic-release).

Since I am currently in the process of setting up the project, and don’t have anyone using my releases yet, I’ve tried deleting the releases, as well as the tags from Github, but I keep getting the same behaviour. The first time I run the release script, it creates a tag v1.0.0 on the commit that was the last commit when I first got semantic-release to work correctly with Github. Then it correctly makes a new release based on the commits since that one. But the next time I run the release script, it finds v1.0.0 again, instead of the latest release that it just created (currently v1.1.0). Then it parses all the commits since v1.0.0 and concludes that it should bump the minor version, bumps it to v1.1.0 and then promptly fails when trying to push this new release to Github, since that tag already exists.

Expected behavior

It should find the release of v1.1.0, and bump the version to v1.2.0.

Environment

  • semantic-release version: 15.6.1
  • CI environment: Jenkins
  • Plugins used: None, except for the built in npm and github, that are used by default.
  • semantic-release configuration: In package.json: "release": { "branch": "master", "debug": true }
  • CI logs:
[lime_lime-elements_master-BNNHCDJPBPTMZM3URF6ONQSA4FS6PQOTS4D4CWAKBMXFMHC7YKNA] Running shell script
+ make release
docker run --rm -e CI -e GH_TOKEN -e NPM_TOKEN -w /lime lime-elements npx semantic-release
[Semantic release]: Running semantic-release version 15.6.1
[Semantic release]: Load plugin "verifyConditions" from @semantic-release/npm
[Semantic release]: Load plugin "verifyConditions" from @semantic-release/github
[Semantic release]: Load plugin "analyzeCommits" from @semantic-release/commit-analyzer
[Semantic release]: Load plugin "generateNotes" from @semantic-release/release-notes-generator
[Semantic release]: Load plugin "prepare" from @semantic-release/npm
[Semantic release]: Load plugin "publish" from @semantic-release/npm
[Semantic release]: Load plugin "publish" from @semantic-release/github
[Semantic release]: Load plugin "success" from @semantic-release/github
[Semantic release]: Load plugin "fail" from @semantic-release/github
[Semantic release]: Run automated release from branch master
[Semantic release]: Call plugin verify-conditions
[Semantic release]: Verify authentication for registry http://npm.lundalogik.com:4873/
[Semantic release]: Wrote NPM_TOKEN to .npmrc.
[Semantic release]: Verify GitHub authentication
[Semantic release]: Found git tag v1.0.0 associated with version 1.0.0
[Semantic release]: Found 15 commits since last release
[Semantic release]: Call plugin analyze-commits
[Semantic release]: Analyzing commit: feat(CI): dummy minor bump
[Semantic release]: The release type for the commit is minor
[Semantic release]: Analyzing commit: chore(CI): try to get semantic-release to work correctly
[Semantic release]: The commit should not trigger a release
[Semantic release]: Analyzing commit: chore(CI): update access token used
[Semantic release]: The commit should not trigger a release
[Semantic release]: Analyzing commit: chore(CI): update Dockerfile
[Semantic release]: The commit should not trigger a release
[Semantic release]: Analyzing commit: chore(CI): update semantic-release
[Semantic release]: The commit should not trigger a release
[Semantic release]: Analyzing commit: docs(README): Fix bad link formatting
[Semantic release]: The commit should not trigger a release
[Semantic release]: Analyzing commit: feat(README): Improve readme

Also use the `feat` type to bump the minor version, to fix an
issue with semantic-release, probably caused by force-pushing to
master.
[Semantic release]: The release type for the commit is minor
[Semantic release]: Analyzing commit: docs(README): Add commit message guidelines
[Semantic release]: The commit should not trigger a release
[Semantic release]: Analyzing commit: chore: Uppercase readme file
[Semantic release]: The commit should not trigger a release
[Semantic release]: Analyzing commit: fix(CI): Debug flag removed
[Semantic release]: The release type for the commit is patch
[Semantic release]: Analyzing commit: CHANGELOG.md no longer needed

Changelog is now found on each release in Github.
[Semantic release]: The commit should not trigger a release
[Semantic release]: Analyzing commit: The docker build no longer runs the npm build
[Semantic release]: The commit should not trigger a release
[Semantic release]: Analyzing commit: fix(semantic-release): Pass env-vars to container
[Semantic release]: The release type for the commit is patch
[Semantic release]: Analyzing commit: fix(semantic-release): Fixes bug in Makefile
[Semantic release]: The release type for the commit is patch
[Semantic release]: Analyzing commit: fix(semantic-release): Fixes for npm publish

Run `npm publish` in the correct environment when releasing.
[Semantic release]: The release type for the commit is patch
[Semantic release]: Analysis of 15 commits complete: minor release
[Semantic release]: The next release version is 1.1.0
[Semantic release]: Call plugin verify-release
[Semantic release]: Call plugin generateNotes
[Semantic release]: Call plugin prepare
[Semantic release]: Wrote version 1.1.0 to package.json
[Semantic release]: Wrote version 1.1.0 to package-lock.json
[Semantic release]: Create tag v1.1.0
[Semantic release]: An error occurred while running semantic-release: { Error: Command failed: git push --tags https://[secure]@github.com/Lundalogik/lime-elements.git HEAD:master
To https://[secure]@github.com/Lundalogik/lime-elements.git
 ! [rejected]        v1.1.0 -> v1.1.0 (already exists)
error: failed to push some refs to 'https://[secure]@github.com/Lundalogik/lime-elements.git'
hint: Updates were rejected because the tag already exists in the remote.


    at makeError (/lime/node_modules/semantic-release/node_modules/execa/index.js:172:9)
    at Promise.all.then.arr (/lime/node_modules/semantic-release/node_modules/execa/index.js:277:16)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  code: 1,
  stdout: '',
  stderr: 'To https://[secure]@github.com/Lundalogik/lime-elements.git\n ! [rejected]        v1.1.0 -> v1.1.0 (already exists)\nerror: failed to push some refs to \'https://[secure]@github.com/Lundalogik/lime-elements.git\'\nhint: Updates were rejected because the tag already exists in the remote.\n',
  failed: true,
  signal: null,
  cmd: 'git push --tags https://[secure]@github.com/Lundalogik/lime-elements.git HEAD:master',
  timedOut: false,
  killed: false }
{ Error: Command failed: git push --tags https://****@github.com/Lundalogik/lime-elements.git HEAD:master
To https://****@github.com/Lundalogik/lime-elements.git
 ! [rejected]        v1.1.0 -> v1.1.0 (already exists)
error: failed to push some refs to 'https://****@github.com/Lundalogik/lime-elements.git'
hint: Updates were rejected because the tag already exists in the remote.


    at makeError (/lime/node_modules/semantic-release/node_modules/execa/index.js:172:9)
    at Promise.all.then.arr (/lime/node_modules/semantic-release/node_modules/execa/index.js:277:16)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  code: 1,
  stdout: '',
  stderr: 'To https://****@github.com/Lundalogik/lime-elements.git\n ! [rejected]        v1.1.0 -> v1.1.0 (already exists)\nerror: failed to push some refs to \'https://****@github.com/Lundalogik/lime-elements.git\'\nhint: Updates were rejected because the tag already exists in the remote.\n',
  failed: true,
  signal: null,
  cmd: 'git push --tags https://****@github.com/Lundalogik/lime-elements.git HEAD:master',
  timedOut: false,
  killed: false }
Makefile:15: recipe for target 'release' failed
make: *** [release] Error 1

I assume this is probably not a bug, but something I’m doing wrong, but I haven’t been able to find what, so any ideas are highly appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Ah. I found out Jenkins doesn’t check out tags by default.

To fix the issue, I had to add an “Advanced Clone Behaviours” entry in the “Behaviours” in the Project Configuration, and have the “Fetch tags” option checked.

Now releases work just fine! Thanks for creating this awesome tool!

For anyone coming from Google I had the same problem with GitLab. If you go in your CI/CD settings of your repository you can switch to using git clone from git fetch for cloning the repo in your pipelines and it just fixed the problem for us.