Created
April 29, 2019 09:59
-
-
Save andrew7baker/62c0fec861e2897020a0387d4f9c4df6 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env groovy | |
node { | |
stage('checkout') { | |
checkout scm | |
} | |
stage('check java') { | |
sh "java -version" | |
} | |
stage('clean') { | |
sh "chmod +x mvnw" | |
sh "./mvnw clean" | |
} | |
stage('install tools') { | |
sh "./mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-npm -DnodeVersion=v10.15.0 -DnpmVersion=6.4.1" | |
} | |
stage('npm install') { | |
sh "./mvnw com.github.eirslett:frontend-maven-plugin:npm" | |
} | |
stage('backend tests') { | |
try { | |
sh "./mvnw test" | |
} catch(err) { | |
throw err | |
} finally { | |
junit '**/target/surefire-reports/TEST-*.xml' | |
} | |
} | |
stage('frontend tests') { | |
try { | |
sh "./mvnw com.github.eirslett:frontend-maven-plugin:npm -Dfrontend.npm.arguments='run test'" | |
} catch(err) { | |
throw err | |
} finally { | |
junit '**/target/test-results/TESTS-*.xml' | |
} | |
} | |
stage('packaging') { | |
sh "./mvnw verify -Pprod -DskipTests" | |
archiveArtifacts artifacts: '**/target/*.war', fingerprint: true | |
} | |
def dockerImage | |
stage('build docker') { | |
sh "cp -R src/main/docker target/" | |
sh "cp target/*.war target/docker/" | |
dockerImage = docker.build('docker-login/demo', 'target/docker') | |
} | |
stage('publish docker') { | |
docker.withRegistry('https://registry.hub.docker.com', 'docker-login') { | |
dockerImage.push 'latest' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment