forked from RestComm/jss7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
91 lines (85 loc) · 3.23 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
pipeline {
agent any
tools {
jdk 'JDK 11'
maven 'maven3.6.1'
}
parameters {
string(name: 'jSS7_MAJOR_VERSION_NUMBER', defaultValue: '8.3.0', description: 'The major version for RestComm jSS7')
string(name: 'SCTP_MAJOR_VERSION_NUMBER', defaultValue: '2.0.2', description: 'The major version of RestComm SCTP for RestComm jSS7')
string(name: 'SCTP_BUILD', defaultValue: '13', description: 'The build number of RestComm SCTP for RestComm jSS7 to use for the build')
// booleanParam(name: 'BUILD_ANT', defaultValue: true, description: 'Enable if Binary needs to be generated')
}
stages {
stage('Set Version') {
steps {
script {
if (BUILD_NUMBER == "1") {
error "Building for the first time"
}
}
sh "mvn versions:set -DnewVersion=${params.jSS7_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER}"
echo "Setting version to ${params.jSS7_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER} completed"
}
}
stage("Build") {
steps {
script {
RestComm_SCTP_VERSION = "${params.SCTP_MAJOR_VERSION_NUMBER}-${params.SCTP_BUILD}"
currentBuild.displayName = "#${params.jSS7_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER}"
currentBuild.description = "RestComm jSS7 build"
}
echo "Building RestComm jSS7 version (#${params.jSS7_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER})"
sh "mvn clean install -Dsctp.version=${RestComm_SCTP_VERSION} -Dss7.restcomm.version=${params.jSS7_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER} -DskipTests"
echo "Maven build completed."
}
}
stage("Ant") {
// when { expression { params.BUILD_ANT.toBoolean() == true}}
steps {
script {
RestComm_SCTP_VERSION = "${params.SCTP_MAJOR_VERSION_NUMBER}-${params.SCTP_BUILD}"
}
echo "Starting ant build for version #${params.jSS7_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER}"
withAnt(installation: 'Ant1.10') {
dir('release'){
sh "ant -f build.xml -Drelease.version=${params.jSS7_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER} -Dsctp.version=${RestComm_SCTP_VERSION}"
}
}
}
}
stage('Save Artifacts') {
steps {
echo "Archiving RestComm-jSS7-${params.jSS7_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER}"
archiveArtifacts artifacts: "release/RestComm-jSS7-${params.jSS7_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER}.zip", followSymlinks: false, onlyIfSuccessful: true
}
}
stage('Push to Repo') {
when { anyOf { branch 'master'; branch 'release' } }
steps {
sshagent(['ssh_grafana']) {
sh "scp release/RestComm-jSS7-${params.jSS7_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER}.zip [email protected]:/var/www/html/RestComm/jss7/"
}
}
}
stage('Push to jFrog') {
when {anyOf {branch 'master'; branch 'release'}}
steps {
sh 'mvn deploy -DskipTests'
}
}
}
post {
success {
echo "Successfully build"
}
failure{
script{
currentBuild.description = "RestComm jSS7 build - failed"
}
}
always {
echo "This will be called always. After testing do clean up"
}
}
}