Skip to content

Instantly share code, notes, and snippets.

@mosinski
Last active September 24, 2018 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosinski/6e101460832a24f29e5eec897fd40879 to your computer and use it in GitHub Desktop.
Save mosinski/6e101460832a24f29e5eec897fd40879 to your computer and use it in GitHub Desktop.
curl -u Jenkins:Jenkins -H "Content-Type: application/json" -X POST http://localhost:7990/rest/build-status/1.0/commits/$GIT_COMMIT -d '{"state":"INPROGRESS","key": "'$BUILD_TAG'","name": "Jenkins-'$BUILD_DISPLAY_NAME'", "url": "'$BUILD_URL'/consoleText","description": "Changes by '$GIT_COMMITTER_EMAIL'"}'

#!/bin/sh
cd ${WORKSPACE}
SUCCESS=true

gem install bundler --no-rdoc --no-ri || SUCCESS=false
bundle install || SUCCESS=false
bundle exec rake db:create || SUCCESS=false
bundle exec rake db:migrate RAILS_ENV=test || SUCCESS=false
bundle exec rails test || SUCCESS=false

if $SUCCESS; then
  curl -u Jenkins:Jenkins -H "Content-Type: application/json" -X POST http://localhost:7990/rest/build-status/1.0/commits/$GIT_COMMIT -d '{"state":"SUCCESSFUL","key": "'$BUILD_TAG'","name": "Jenkins-'$BUILD_DISPLAY_NAME'", "url": "'$BUILD_URL'/consoleText","description": "Changes by '$GIT_COMMITTER_EMAIL'"}';
else
  curl -u Jenkins:Jenkins -H "Content-Type: application/json" -X POST http://localhost:7990/rest/build-status/1.0/commits/$GIT_COMMIT -d '{"state":"FAILED","key": "'$BUILD_TAG'","name": "Jenkins-'$BUILD_DISPLAY_NAME'", "url": "'$BUILD_URL'/consoleText","description": "Changes by '$GIT_COMMITTER_EMAIL'"}';
  raise error "Build Failed"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment