Skip to content

Instantly share code, notes, and snippets.

@connieho15
Created December 22, 2017 19:08
Show Gist options
  • Save connieho15/958ca22a7778ce9f7562f4bf29b77483 to your computer and use it in GitHub Desktop.
Save connieho15/958ca22a7778ce9f7562f4bf29b77483 to your computer and use it in GitHub Desktop.
#!groovy
def slackChannel = "#team-slackchannel"
properties([
parameters([
string(name: 'releaseType', description: "major, minor, or patch", defaultValue: 'minor')
])
])
node('slave-medium') {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm', 'defaultFg': 1, 'defaultBg': 2]) {
wrap([$class: 'TimestamperBuildWrapper']) {
env.RELEASE_TYPE = releaseType
try {
stage('checkout') {
checkout scm
}
stage('npm install') {
sh "yarn install"
}
stage('unit tests'){
sh "yarn test"
}
if (env.BRANCH_NAME == 'master') {
stage('push to artifactory') {
sh "yarn run precompile"
sh "npm version ${env.RELEASE_TYPE}"
sh "git push origin HEAD:master --follow-tags"
sh "npm publish"
}
stage('notify slack') {
slackSend channel: slackChannel, color: '#2ECC71', message: "Push ${JOB_NAME} (release type: ${env.RELEASE_TYPE}) to Artifactory - Complete - <${BUILD_URL}|See the build>"
}
}
}
catch(error) {
slackSend channel: slackChannel, color: '#CC3D2E', message: "Push ${JOB_NAME} (release type: ${env.RELEASE_TYPE}) to Artifactory - Failed - <${BUILD_URL}|See the build>"
currentBuild.result = "FAILURE"
throw error
}
stage('clean workspace') {
cleanWs()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment