2017-10-06 17:13:45 +02:00
|
|
|
#!groovy
|
2016-12-19 15:56:30 +01:00
|
|
|
// Jenkinsfile (Pipeline Script)
|
|
|
|
|
node {
|
2016-12-19 17:24:07 +01:00
|
|
|
// Configure environment
|
|
|
|
|
env.REPO_URL = "repo.koc.se/zutil-java.git" //scm.getUserRemoteConfigs()[0].getUrl()
|
|
|
|
|
env.BUILD_NAME = "BUILD-" + env.BUILD_ID
|
2016-12-19 16:16:39 +01:00
|
|
|
|
2017-10-06 17:13:45 +02:00
|
|
|
stage('Checkout') {
|
|
|
|
|
git url: "https://" + env.REPO_URL
|
|
|
|
|
}
|
2016-12-19 15:56:30 +01:00
|
|
|
|
2017-10-06 17:13:45 +02:00
|
|
|
withMaven(jdk: "jdk8", maven: "m3.5", mavenLocalRepo: ".repository") {
|
2016-12-19 15:56:30 +01:00
|
|
|
|
2017-10-06 16:37:36 +02:00
|
|
|
stage('Build') {
|
|
|
|
|
sh 'mvn clean compile'
|
2016-12-19 15:56:30 +01:00
|
|
|
}
|
|
|
|
|
|
2017-10-06 16:37:36 +02:00
|
|
|
stage('Test') {
|
2017-10-06 17:13:45 +02:00
|
|
|
sh 'mvn test'
|
2017-10-06 16:37:36 +02:00
|
|
|
}
|
2016-12-19 15:56:30 +01:00
|
|
|
|
2017-10-06 16:37:36 +02:00
|
|
|
stage('Package') {
|
|
|
|
|
sh 'mvn -DskipStatic -DskipTests install'
|
2016-12-19 17:02:55 +01:00
|
|
|
|
2017-10-06 16:37:36 +02:00
|
|
|
// Tag artifact
|
|
|
|
|
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'f8e5f6c6-4adb-4ab2-bb5d-1c8535dff491',
|
2017-10-06 17:13:45 +02:00
|
|
|
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
|
2017-10-06 16:37:36 +02:00
|
|
|
sh "git tag ${env.BUILD_NAME}"
|
|
|
|
|
sh "git push 'https://${USERNAME}:${PASSWORD}@${env.REPO_URL}' ${env.BUILD_NAME}"
|
|
|
|
|
}
|
2016-12-19 17:02:55 +01:00
|
|
|
}
|
2016-12-19 15:56:30 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-20 17:22:58 +01:00
|
|
|
//stage('Deploy') {
|
2017-10-06 16:37:36 +02:00
|
|
|
// timeout(time: 5, unit: 'HOURS') {
|
|
|
|
|
// input message: 'Deploy?', submitter: 'ziver'
|
|
|
|
|
// node {
|
|
|
|
|
// sh 'mvn deploy'
|
|
|
|
|
// }
|
2016-12-20 17:22:58 +01:00
|
|
|
// }
|
|
|
|
|
//}
|