forked from RestComm/jdiameter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
89 lines (79 loc) · 2.61 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
pipeline {
agent any
tools {
jdk 'JDK 11'
maven 'Maven_3.6.3'
}
options {
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: '10'))
}
parameters { string(name: 'JDIAMETER_MAJOR_VERSION_NUMBER', defaultValue: '1.7.4', description: 'The major version for Extended-jDiameter') }
stages {
stage("Build") {
steps {
echo "Building application..."
script {
currentBuild.displayName = "#${params.JDIAMETER_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER}"
currentBuild.description = "RestComm-jDiameter"
}
sh "mvn clean install -DskipTests"
echo "Maven build completed."
}
}
stage('Set Version') {
steps{
sh "mvn versions:set -DnewVersion=${params.JDIAMETER_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER} clean install -DskipTests"
}
}
stage("Release") {
steps {
echo "Building a release version of #${params.JDIAMETER_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER}"
withAnt(installation: 'Ant1.10') {
dir('release') {
sh "rm -rf restcomm-diameter*.zip"
sh "ant -f build.xml -Ddiameter.release.version=${params.JDIAMETER_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER}"
}
}
echo "Building a release version completed."
}
}
stage('Save Artifacts') {
//when { anyOf { branch 'master'; branch 'release' } }
steps {
echo "Archiving Extended jDiameter version ${params.JDIAMETER_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER}"
archiveArtifacts artifacts: "release/*.zip", followSymlinks: false, onlyIfSuccessful: true
}
}
stage('Push Artifacts') {
when{ anyOf { branch 'master'; branch 'release' }}
steps{
script{
ROOT_PATH = "/var/www/html/RestComm/restcomm_jdiameter/${params.JDIAMETER_MAJOR_VERSION_NUMBER}-${BUILD_NUMBER}/"
}
sshagent(['ssh_grafana']) {
sh "ssh [email protected] \"mkdir -p ${ROOT_PATH}\""
sh "scp -r release/*.zip [email protected]:${ROOT_PATH}"
}
}
}
stage('Push to jFrog') {
when {anyOf {branch 'master'; branch 'release'}}
steps {
sh 'mvn deploy -DskipTests'
}
}
}
post {
success {
echo "Successfully built"
}
failure {
echo "Building Extended jDiameter failed."
}
always {
echo "This will be called always. After testing do clean up."
sh 'rm -rf release/checkout'
sh 'rm -rf release/target'
}
}
}