-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathJenkinsfile
105 lines (100 loc) · 3.51 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
@Library("titan-library") _
pipeline {
agent {
label 'linux'
}
triggers {
//cron(cron_string)
gitlab(triggerOnPush: true, triggerOnMergeRequest: true, branchFilterType: 'All')
}
options {
// Set this to true if you want to clean workspace during the prep stage
skipDefaultCheckout(true)
// Console debug options
timestamps()
ansiColor('xterm')
gitLabConnection('gitlab-installer-connection')
}
tools {
jdk 'default'
maven 'default'
}
stages {
stage('Initialize') {
steps {
// Clean before checkout / build
cleanWs()
checkout scm
// Get the release information
script {
pomModel = readMavenPom(file: 'pom.xml')
pomVersion = pomModel.getVersion()
isSnapshot = pomVersion.contains("-SNAPSHOT")
pomGroupId = pomModel.groupId
pomArtifactId = pomModel.artifactId
echo "pomVersion: ${pomVersion}"
echo "isSnapshot: ${isSnapshot}"
echo "pomGroupId: ${pomGroupId}"
echo "pomArtifactId: ${pomArtifactId}"
}
}
}
stage('Build PDF') {
steps {
updateGitlabCommitStatus name: 'build', state: 'running'
sh """
mvn clean install
"""
}
}
stage('Deploy PDF for Release Versions') {
when{
expression{
!isSnapshot && BRANCH_NAME == 'main'
}
}
steps {
updateGitlabCommitStatus name: 'deploy', state: 'running'
configFileProvider([configFile(fileId: 'settings.xml', variable: 'MAVEN_SETTINGS')]) {
sh """
mvn deploy:deploy-file \
--batch-mode \
-e \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
-s ${MAVEN_SETTINGS} \
-Dfile=\$(find statements/target/site/docbook -name symbolic-information-analytics*.pdf) \
-Durl=https://nexus.build.tinkarbuild.com/repository/maven-releases/ \
-DgroupId=${pomGroupId} \
-DartifactId=${pomArtifactId} \
-Dversion=${pomVersion} \
-Dtype=pdf \
-Dpackaging=pdf \
-DrepositoryId=titan-maven-releases
"""
}
}
post {
failure {
updateGitlabCommitStatus name: 'deploy', state: 'failed'
}
success {
updateGitlabCommitStatus name: 'deploy', state: 'success'
}
aborted {
updateGitlabCommitStatus name: 'deploy', state: 'canceled'
}
}
}
}
post {
failure {
updateGitlabCommitStatus name: 'build', state: 'failed'
}
success {
updateGitlabCommitStatus name: 'build', state: 'success'
}
aborted {
updateGitlabCommitStatus name: 'build', state: 'canceled'
}
}
}