-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
53 lines (49 loc) · 1.84 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
pipeline {
agent any
tools {
maven "Maven 3.9"
}
environment {
BUILD_VERSION = VersionNumber (versionNumberString: '${BUILD_YEAR}.${BUILD_MONTH}.${BUILDS_THIS_MONTH}')
//JOB_NAME
}
stages {
stage('Increment Version') {
steps {
echo "Incrementing version ... $BUILD_VERSION"
sh "mvn versions:set -DnewVersion=\\${BUILD_VERSION} versions:commit"
}
}
stage('Build Jar') {
steps {
echo "Building Jar ..."
sh "mvn clean package" // Adding clean removes any old .jar packages in target folder
}
}
stage('Build Docker') {
environment {
DOCKERHUB_CREDS = credentials('dockerhub-creds')
}
steps {
echo "Building Docker ..."
sh "docker build -t juronja/$JOB_NAME:$BUILD_VERSION -t juronja/$JOB_NAME:latest ."
// Next line in single quotes for security
sh 'echo $DOCKERHUB_CREDS_PSW | docker login -u $DOCKERHUB_CREDS_USR --password-stdin'
sh "docker push juronja/$JOB_NAME:$BUILD_VERSION"
sh "docker push juronja/$JOB_NAME:latest"
}
}
// stage('Build Docker Nexus') {
// environment {
// NEXUS_CREDS = credentials('nexus-creds')
// }
// steps {
// echo "Building Docker Nexus ..."
// sh "docker build -t 64.226.97.173:8082/$JOB_NAME:1.1 ."
// // Next line in single quotes for security
// sh 'echo $NEXUS_CREDS_PSW | docker login -u $NEXUS_CREDS_USR --password-stdin 64.226.97.173:8082'
// sh "docker push 64.226.97.173:8082/$JOB_NAME:1.1"
// }
// }
}
}