Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run on Jenkins #329

Closed
kreck opened this issue Nov 17, 2016 · 10 comments
Closed

Unable to run on Jenkins #329

kreck opened this issue Nov 17, 2016 · 10 comments

Comments

@kreck
Copy link

kreck commented Nov 17, 2016

I prefer using Jenkins instead of Travis but i am unable to get semantic-release running on the Jenkins Server.

This the error thrown when running on Jenkins:

semantic-release ERR! commits This means semantic-release can not extract the commits between now and then.
semantic-release ERR! commits This is usually caused by force pushing, releasing from an unrelated branch, or using an already existing package name.
semantic-release ERR! commits You can recover from this error by publishing manually or restoring the commit "4ee416bb0a1e21d43cae4b04314e788041624577".
semantic-release ERR! commits Here is a list of branches that still contain the commit in question: 
semantic-release ERR! commits  * * (detached from 4ee416b)
semantic-release ERR! pre Failed to determine new version.
semantic-release ERR! pre ENOTINHISTORY Commit not in history

It does however run locally on my machine without any problem.

Things i tried:

  • completely wipe workspace on Jenkins (no change, problem persists)
  • make sure Jenkins prunes and does a fresh (full) clone on every build (no change, problem persists)
  • try local "manual" semantic-release on another machine (works just fine)

I'd be glad for any hints that point me in the right direction....

@zakhenry
Copy link

@kreck the issue arises from the fact that jenkins checks out the head commit directly and the tree is in a "detatched HEAD state". You can resolve this in jenkins by just running git checkout master or whatever your branch is. Ideally semantic-release would be able to handle detached HEADs however, so this should not resolve this issue, just add clarity

@kreck
Copy link
Author

kreck commented Nov 18, 2016

@zakhenry you saved my Friday evening. It is working. Thank you very much!

@janppires
Copy link

Hi @kreck! Could you share your semantic-release configuration integrated with jenkins? I do not find enough information about that. Many thanks

@kreck
Copy link
Author

kreck commented Mar 8, 2017

@janppires Sure, first you add the relevant tokens (GiHub/npm) to the credentials keychain in Jenkins. Then you simply set up a build task (in my case triggered via GitHub Webhooks). Make sure node is available in your PATH and simply run a "Shell" build script:

git checkout master
set +x
export NPM_TOKEN=${NPM_TOKEN}
export GH_TOKEN=${GH_TOKEN}
set -x
npm prune
npm install
npm run cover
npm run check-coverage
npm run build
npm run semantic-release

Hope that helps....

@janppires
Copy link

Thanks @kreck ! That seems easy!

Another problem I have is the fact that I do not want to use the default npm repo. I need to figure out how to setup artifactory instead.

zot24 added a commit to moltin/js-sdk that referenced this issue May 4, 2017
@zot24
Copy link

zot24 commented May 4, 2017

Hi guys! what about the verifyConditions? I'm getting the following:

semantic-release WARN pre semantic-release didn't run on Travis CI and therefore a new version won't be published.
semantic-release WARN pre You can customize this behavior using "verifyConditions" plugins: git.io/sr-plugins

And can make it work on Jenkins I have found this https://github.com/krux/condition-jenkins but not sure if it will be needed/required

Thanks,

ynnoj pushed a commit to moltin/js-sdk that referenced this issue May 4, 2017
* chg: add Jenkinsfile

At the minute it will just run the tests

* chg: add semantic-release-cli

* chg: add missed npm install

* Use correct semantic-release commands

* fix: command to be exec inside the docker image

* fix: semantic-release-cli command

* fix: misunderstanding with -cli

(๑˃̵ᴗ˂̵)و

* chg: use G/H token instead of ssh key

* fix: checkout master

Following semantic-release/semantic-release#329

* fix: change approach and use sh command for docker for the semantic command

* Add release block to package.json for semantic-release configuration

* chg: add check for master branch

* chg: improve slack message

* fix: run tests on any branch not just master
@zot24
Copy link

zot24 commented May 4, 2017

We kind of fix part of the problem using the project mention before and adding this to our package.json

"release": {
   "branch": "master",
   "verifyConditions": {
     "path": "./node_modules/@krux/condition-jenkins"
   }
 }

And our Jenkins command that will run the semantic-release pre looks like:

 sh "docker run -v \$(pwd):/data -w /data -e GIT_BRANCH=\"origin/master\" -e JENKINS_URL=${env.JENKINS_URL} -e GH_TOKEN=$GH_TOKEN -e CI=true -e NPM_TOKEN=\"$NPM_TOKEN\" zot24/semantic-release semantic-release pre"

However still getting an error this time a different one

semantic-release ERR! pre The header content contains invalid characters TypeError: The header content contains invalid characters

Any ideas?

Thanks,

@zot24
Copy link

zot24 commented May 4, 2017

It's have to be something related with how Jenkisfile process the commands, some kind of encoding error I think because the command it self works perfectly if you run it manually from the shell either local or from the Jenkins server host

@zot24
Copy link

zot24 commented May 5, 2017

Problem solve it behaved different because the way I was getting the token on the Jenkinsfile was different that when I execute the command from the host, check for more info npm/npm-registry-client#159 ta

If it does helps someone this is how our Jenkinsfile looks like https://github.com/moltin/js-sdk/blob/master/Jenkinsfile

@pvdlg
Copy link
Member

pvdlg commented Nov 21, 2017

Closing as the problem seems to be solved. Please reopen if it's not the case

@pvdlg pvdlg closed this as completed Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants