Skip to content

Instantly share code, notes, and snippets.

@nhernandezga-old
Forked from connieho15/Jenkinsfile.groovy
Created December 13, 2018 15:43
Show Gist options
  • Save nhernandezga-old/8e83ea53d4c8f17c7be6c96dd11921ff to your computer and use it in GitHub Desktop.
Save nhernandezga-old/8e83ea53d4c8f17c7be6c96dd11921ff 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