forked from CourseOrchestra/celesta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReleaseJenkinsfile
111 lines (97 loc) · 3.88 KB
/
ReleaseJenkinsfile
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
properties(
[
pipelineTriggers([
triggers: [
[
$class: 'hudson.triggers.SCMTrigger',
scmpoll_spec : 'H 0 * * 0'
]
]
])
]
)
node {
def server = Artifactory.server 'ART'
def rtMaven = Artifactory.newMavenBuild()
def buildInfo
def descriptor
def releaseVersion
stage ('Clone') {
checkout scm
sh '''git checkout dev'''
result = sh (script: "git log -1 | grep '\\[ci skip\\]'", returnStatus: true)
if (result == 0) {
currentBuild.result = 'SUCCESS'
return
}
}
stage ('Artifactory configuration') {
rtMaven.tool = 'M3'
rtMaven.deployer releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot-local', server: server
rtMaven.resolver releaseRepo: 'libs-release', snapshotRepo: 'libs-snapshot', server: server
rtMaven.deployer.artifactDeploymentPatterns.addExclude("*celesta-test*").addExclude("*dbschemasync*")
buildInfo = Artifactory.newBuildInfo()
buildInfo.env.capture = true
descriptor = Artifactory.mavenDescriptor()
pom = readMavenPom file: 'pom.xml'
releaseVersion = pom.version.split('-')[0]
descriptor.version = releaseVersion
descriptor.failOnSnapshot = true
descriptor.transform()
}
stage ('Make release') {
rtMaven.run pom: 'pom.xml', goals: '-Dmaven.test.skip=true clean install -P corchestra-release', buildInfo: buildInfo
server.publishBuildInfo buildInfo
def distributionConfig = [
// Mandatory parameters
'buildName' : buildInfo.name,
'buildNumber' : buildInfo.number,
'targetRepo' : 'orchestra',
// Optional parameters
'overrideExistingFiles' : true // Default: false. If true, Artifactory overwrites builds already existing in the target path in Bintray.
]
server.distribute distributionConfig
}
stage ('Update repository') {
sh '''git add .'''
def commitReleaseScript = "git commit -m \"updating poms for " + releaseVersion + " release [ci skip]\""
sh commitReleaseScript
def tagScript = "git tag " + releaseVersion
sh tagScript
def splittedVersion = releaseVersion.split('\\.')
splittedVersion[2] = (splittedVersion[2].toInteger() + 1) as String
def newSnapshotVersion = splittedVersion.join('.') + '-SNAPSHOT'
descriptor.version = newSnapshotVersion
descriptor.failOnSnapshot = false
descriptor.transform()
sh '''git add .'''
def commitSnapshotScript = "git commit -m \"updating poms for " + newSnapshotVersion + " development [ci skip]\""
sh commitSnapshotScript
sshagent(['cf816ae4-a98e-4eaa-98fd-18c588739711']) {
sh '''git push origin dev'''
sh '''git push --tags'''
}
}
stage ('Sync with maven central') {
def modules = ['celesta-parent',
'celesta-sql',
'celesta-core',
'celesta-maven-plugin',
'celesta-system-services',
'celesta-unit']
withCredentials([usernamePassword(credentialsId: 'curs-bintray', passwordVariable: 'bintrayPassword', usernameVariable: 'bintrayUserName')]) {
for (module in modules) {
def shScript = "\\" +
"curl --verbose \\" +
"-s \\" +
"--connect-timeout 240 \\" +
"--max-time 2700 \\" +
"-u $bintrayUserName:$bintrayPassword \\" +
"-f \\" +
"-X \\" +
"POST \"https://api.bintray.com/maven_central_sync/courseorchestra/libs-release-local/" + module + "/versions/" + releaseVersion + "\""
sh shScript
}
}
}
}