-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
70 lines (68 loc) · 2.1 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
pipeline {
agent any
environment {
MAJOR_VERSION = 1
}
stages {
stage('build') {
steps {
sh 'javac -d . src/*.java'
sh 'echo Main-Class: Rectangulator > MANIFEST.MF'
sh 'jar -cvmf MANIFEST.MF rectangle.jar *.class'
}
post {
success {
archiveArtifacts artifacts: 'rectangle.jar', fingerprint: true
}
}
}
stage('run') {
steps {
sh 'java -jar rectangle.jar 7 9'
}
}
stage('Promote Development to Master') {
when {
branch 'development'
}
steps {
echo "Stashing Local Changes"
sh "git stash"
echo "Checking Out Development"
sh 'git checkout development'
sh 'git pull origin'
echo 'Checking Out Master'
sh 'git checkout master'
echo "Merging Development into Master"
sh 'git merge development'
echo "Git Push to Origin"
sh 'git push origin master'
}
post {
success { emailext(
subject: "${env.JOB_NAME} [${env.BUILD_NUMBER}] Development Promoted to Master",
body: """<p>'${env.JOB_NAME} [${env.BUILD_NUMBER}]' Development Promoted to Master":</p>
<p>Check console output at <a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></p>""",
to: "[email protected]")
}
}
}
stage('Tagging the Release') {
when {
branch 'master'
}
steps {
sh "git tag rectangle-${env.MAJOR_VERSION}.${BUILD_NUMBER}"
sh "git push origin rectangle-${env.MAJOR_VERSION}.${BUILD_NUMBER}"
}
post {
success { emailext(
subject: "${env.JOB_NAME} [${env.BUILD_NUMBER}] Development Promoted to Master",
body: """<p>'${env.JOB_NAME} [${env.BUILD_NUMBER}]' Development Promoted to Master":</p>
<p>Check console output at <a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></p>""",
to: "[email protected]")
}
}
}
}
}