-
Notifications
You must be signed in to change notification settings - Fork 66
/
Jenkinsfile
121 lines (108 loc) · 4.32 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**********************************************************************************
* JenkinsFile for InMoov2
*
* for adjusting build number for specific branch build
* Jenkins.instance.getItemByFullName("InMoov2-multibranch/develop").updateNextBuildNumber(185)
*
* CHANGE build.properties TO BUILD AND DEPLOY A NEW BUILD
*
***********************************************************************************/
// [$class: 'GithubProjectProperty', displayName: '', projectUrlStr: 'https://github.com/MyRobotLab/InMoov2/']
def version = "2.0.${env.BUILD_NUMBER}"
def groupId = 'fr.inmoov'
def artifactId = 'inmoov'
pipeline {
// https://plugins.jenkins.io/agent-server-parameter/
// agent { label params['agent-name'] }
agent any
options {
// This is required if you want to clean before build
skipDefaultCheckout(true)
}
// properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '3')), [$class: 'GithubProjectProperty', displayName: '', projectUrlStr: 'https://github.com/MyRobotLab/InMoov2/'], pipelineTriggers([pollSCM('* * * * *')])])
// echo params.agentName
tools {
maven 'M3' // defined in global tools - maven is one of the only installers that works well for global tool
// jdk 'openjdk-11-linux' // defined in global tools
// git
}
stages {
stage('clean') {
steps {
echo 'clean the workspace'
// deleteDir()
cleanWs()
}
}
stage('check out') {
steps {
checkout scm
}
}
stage('build') {
steps {
script {
if (isUnix()) {
sh '''
echo "building ${JOB_NAME}..."
mkdir resource
mkdir resource/InMoov
echo "1.1.${BUILD_NUMBER}" > resource/InMoov/version.txt
'''
} else {
bat('''
type "building ${env.JOB_NAME}..."
mkdir 'resource'
mkdir 'resource/InMoov'
type '1.1.${env.BUILD_NUMBER}' > 'resource/InMoov/version.txt'
''')
} // isUnix
} // script
} // steps
} // stage
stage('zip') {
steps {
script {
if (isUnix()) {
sh "zip -r ${artifactId}-${version}.zip resource"
} else {
bat("tar.exe -r ${artifactId}-${version}.zip resource")
}
// archiveArtifacts artifacts: 'test.zip', fingerprint: true
}
}
}
/**
* deployment locally by installing into maven like repo with nginx serving the repo directory
*/
stage('install') {
steps {
script {
// deployment variables
def path = groupId.replace('.', '/') + '/' + artifactId.replace('.', '/')
def repo = '/repo/artifactory/myrobotlab/' + path + '/'
// if (isUnix()) {
// sh "mkdir -p ${repo}${version}"
// sh "cp ${artifactId}-${version}.zip ${repo}${version}"
// } else {
// bat("tar.exe -r ${artifactId}-${version}.zip resource")
// }
// ${artifactId}-{version}.pom
def depFileName = repo + version + '/' + artifactId + '-' + version + '.pom'
def pom = '<project>\n'
pom += '<modelVersion>4.0.0</modelVersion>\n'
pom += '<modelVersion>4.0.0</modelVersion>\n'
pom += '<groupId>' + groupId + '</groupId>\n'
pom += '<artifactId>' + artifactId + '</artifactId>\n'
pom += '<version>' + version + '</version>\n'
pom += '<description>InMoov2 main service module for InMoov compatible with Nixie release of myrobotlab</description>\n'
pom += '<url>http://myrobotlab.org</url>\n'
pom += '</project>\n'
echo 'writing pom ' + depFileName
writeFile file: depFileName, text: pom
}
}
// sh "cp ${artifactId}-${version}.zip ${repo}latest.release/${artifactId}-latest.release.zip"
}
} // stages
} // pipeline