-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-deploy
77 lines (72 loc) · 2.52 KB
/
Jenkinsfile-deploy
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
def targetVersion
def branches
node {
stage('リリースするバージョンの選択') {
git branch: "master",
credentialsId: 'github',
url: 'https://github.com/ihcomega56/pingpong-server.git'
branches = sh(
script: """
git branch --remotes | sed s/'origin\\/'//g | grep -E "[0-9]+.[0-9]+.[0-9]+\$"
""",
returnStdout: true
)
targetVersion = input(
id: 'targetVersion',
message: 'リリースするバージョンを入力して下さい',
parameters: [
[$class: 'ChoiceParameterDefinition',
name: 'targetVersion',
choices: '1.0.0\n1.1.0',
description: 'リリースするバージョン']
])
}
stage('リリース') {
def spec = "{\"files\": [{\"aql\": {\"items.find\":{\"name\":{\"\$match\":\"pingpong-server-*.war\"}," \
+ "\"\$and\":[{\"@version\":\"${targetVersion}\"}]}}}]}"
rtDownload(
serverId: 'yokota',
buildName: 'pingpong-server',
failNoOp: false,
spec: spec
)
pushToCloudFoundry(
target: 'https://api.us-south.cf.cloud.ibm.com',
organization: "$email",
cloudSpace: 'dev',
credentialsId: 'ibmcloud',
manifestChoice: [appName: 'pingpong-server',
appPath: "com/example/pingpong-server/${targetVersion}-SNAPSHOT/pingpong-server-${targetVersion}-SNAPSHOT.war",
value: "jenkinsConfig"],
pluginTimeout: "180"
)
}
stage('メタデータの更新') {
def deletePropsSpec = '''{
"files": [
{
"aql": {"items.find":{"name":{"$match":"pingpong-server*.war"},"$and":[{"@current":"true"}]}}
}
]
}'''
def setPropsSpec = "{\"files\": [{\"aql\": {\"items.find\":{\"name\":{\"\$match\":\"pingpong-server-*.war\"}," \
+ "\"\$and\":[{\"@version\":\"${targetVersion}\"}]}}}]}"
def server = Artifactory.server 'yokota'
try {
rtDeleteProps(
serverId: 'yokota',
failNoOp: true,
props: "current",
spec: deletePropsSpec
)
} catch (Exception e) {
print "No artifact to be updated"
}
rtSetProps(
serverId: 'yokota',
failNoOp: false,
props: "released=true;current=true",
spec: setPropsSpec
)
}
}