-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathReleaseJenkinsfile
More file actions
131 lines (109 loc) · 4.61 KB
/
ReleaseJenkinsfile
File metadata and controls
131 lines (109 loc) · 4.61 KB
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
122
123
124
125
126
127
128
129
130
131
properties(
[
pipelineTriggers([
triggers: [
[
$class: 'hudson.triggers.SCMTrigger',
scmpoll_spec : 'H 0 * * 0'
]
]
])
]
)
node {
def server = Artifactory.server 'ART'
def rtMaven = Artifactory.newMavenBuild()
def rtNpm = Artifactory.newNpmBuild()
def buildInfo
def descriptor
def releaseVersion
def packagejson
env.NODEJS_HOME = "${tool 'NODE11'}"
env.PATH="${env.NODEJS_HOME}/bin:${env.PATH}"
stage ('Clone') {
checkout scm
sh '''git checkout master'''
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
rtNpm.tool = 'NODE11'
rtNpm.deployer repo: 'npm-local', server: server
rtNpm.resolver repo: 'npm-remote', server: server
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()
packagejson = readJSON file: 'src/main/javascript/lyra/package.json'
packagejson['version'] = releaseVersion
writeJSON file: 'src/main/javascript/lyra/package.json', json: packagejson, pretty: 4
}
stage ('Make release') {
rtMaven.run pom: 'pom.xml', goals: '-Dmaven.test.skip=true clean install -P corchestra-release', buildInfo: buildInfo
rtNpm.publish buildInfo: buildInfo, path: 'src/main/javascript/lyra'
server.publishBuildInfo buildInfo
withCredentials([string(credentialsId: 'nodejs-token', variable: 'NPM_TOKEN')]) {
sh "echo //registry.npmjs.org/:_authToken=${env.NPM_TOKEN} > .npmrc"
sh "npm publish src/main/javascript/lyra"
sh 'rm .npmrc'
}
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 and package.json 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()
packagejson['version'] = newSnapshotVersion
writeJSON file: 'src/main/javascript/lyra/package.json', json: packagejson
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 master'''
sh '''git push --tags'''
}
}
stage ('Sync with maven central') {
def modules = ['lyra']
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
}
}
}
}