Skip to content

Instantly share code, notes, and snippets.

@merken
Last active December 3, 2018 12:20
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 merken/78ce71de45a83ce37b2ccd8dbd3bdce1 to your computer and use it in GitHub Desktop.
Save merken/78ce71de45a83ce37b2ccd8dbd3bdce1 to your computer and use it in GitHub Desktop.
basic Jenkinsfile
//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