forked from Axcient/elastio-snap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_linux_release
124 lines (116 loc) · 2.52 KB
/
Jenkinsfile_linux_release
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
///NOTE: previous build stores in branch feature/old_build_system
@Library('jenkins-utils-lib') _
pipeline {
agent {
label 'dr-linbuild'
}
stages {
stage('Setup parameters') {
steps {
script {
properties([
parameters([
choice(
name: 'DEPLOY_TO',
choices: ['Staging', 'Prod'],
description: 'Deploy to:'
),
string(
defaultValue: '',
name: 'RELEASE_BRANCH',
trim: true
),
string(
defaultValue: '0',
name: 'RELEASE_BUILD',
trim: true
)
])
])
}
}
}
stage('Deploy DEB') {
steps {
script {
deployToDebRepos("${params.RELEASE_BRANCH}", "${params.RELEASE_BUILD}", "${params.DEPLOY_TO}");
}
}
}
stage('Deploy RPM') {
steps {
script {
deployToRpmRepos("${params.RELEASE_BRANCH}", "${params.RELEASE_BUILD}", "${params.DEPLOY_TO}");
}
}
}
}
post {
always {
deleteDir()
}
}
}
def deployToDebRepos(String branch, String build, String deploy_to)
{
def deb_repos = [
'bionic-agent',
'focal-agent',
'jammy-agent',
'bullseye-agent',
'buster-agent',
'bookworm-agent',
] as String[]
def deploy_to_prod = (deploy_to == 'Prod');
deploy(deb_repos, branch, build, deploy_to_prod, 'deb');
}
def deployToRpmRepos(String branch, String build, String deploy_to)
{
def rpm_repos = [
'ootpa',
'maipo',
'plow',
] as String[]
def deploy_to_prod = (deploy_to == 'Prod');
deploy(rpm_repos, branch, build, deploy_to_prod, 'rpm');
}
def deploy(String[] repos, String branch, String build, Boolean deploy_to_prod, String repo_type)
{
repos.each {
def subfolder = it.replace("-agent", "").capitalize();
downloadFileFromArtifactory(
'slc_artifactory',
"replibit/elastio/$branch/$build/$subfolder/*.$repo_type",
"./$subfolder/");
def repo = deploy_to_prod ? it : it + '-stg';
println "Uploading packages from replibit/agent/$branch/$build/$subfolder/*.$repo_type to $repo";
deploy_map = [
dir : subfolder,
map_repo: ['.*': repo],
user: "rbrepo",
];
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
if (repo_type == 'deb') {
deploy_map.agent = "rep-agent";
deployDeb(deploy_map);
} else {
deploy_map.agent = "agent";
deployRpm(deploy_map);
}
}
}
}
def downloadFileFromArtifactory(String artifactoryServerId, String path, String dstFile)
{
rtDownload (
serverId: artifactoryServerId,
spec:
"""{
"files": [{
"pattern": "${path}",
"target": "${dstFile}",
"flat": true
}]
}"""
)
}