Last active
December 3, 2018 12:20
-
-
Save merken/78ce71de45a83ce37b2ccd8dbd3bdce1 to your computer and use it in GitHub Desktop.
basic Jenkinsfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//GLOBAL VARIABLE | |
VERSION_NUMBER = "" | |
/** Pipeline **/ | |
node { | |
ws('myapp') { | |
try{ | |
stage("scm pull") { | |
cloneRepo(); | |
VERSION_NUMBER = "1.2.3" | |
currentBuild.displayName = "$VERSION_NUMBER"; | |
} | |
stage ("build") { | |
build(); | |
} | |
stage ("test") { | |
test(); | |
} | |
stage ("deploy") { | |
deploy(); | |
} | |
stage ("integration test") { | |
integration_test(); | |
} | |
} | |
catch (InterruptedException x) { | |
currentBuild.result = 'ABORTED'; | |
throw x; | |
} | |
catch (e) { | |
currentBuild.result = 'FAILURE'; | |
throw e; | |
} | |
} | |
} | |
def cloneRepo() { | |
checkout scm; | |
} | |
def build(){ | |
dir('app') { | |
sh(script: 'build app', returnStdout: true); | |
} | |
} | |
def test(){ | |
dir('tests') { | |
sh(script: 'test app', returnStdout: true); | |
step([$class: 'XUnitBuilder', | |
thresholds: [[$class: 'FailedThreshold', unstableThreshold: '1']], | |
tools: [[$class: 'JUnitType', pattern: '*.*']]]) | |
} | |
} | |
def deploy(){ | |
dir('app') { | |
sh(script: 'deploy app', returnStdout: true); | |
} | |
} | |
def integration_test(){ | |
sh(script: 'curl https://app.com/login?username=admin&passw=123456', returnStdout: true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment