-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.ci
More file actions
152 lines (140 loc) · 3.61 KB
/
.ci
File metadata and controls
152 lines (140 loc) · 3.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env groovy
// https://github.com/apartmentlist/ci-shared-library
@Library('ci-shared-library')_
// Log Rotation
properties([
buildDiscarder(
logRotator(
artifactDaysToKeepStr: '',
artifactNumToKeepStr: '',
daysToKeepStr: '30',
numToKeepStr: '100'
)
)
]) //properties
// Generate unique slave labels
def k8s_label = "${UUID.randomUUID().toString()}"
pipeline {
environment {
APP_NAME = 'bulk-processor'
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE = 'true'
CI = 'true'
CLOUDSDK_CORE_DISABLE_PROMPTS = '1'
GIT_COMMIT_SHORT = sh(script: "git rev-parse --short ${GIT_COMMIT}", returnStdout: true).trim()
GIT_MESSAGE = sh(script: "git log --format=%B -n 1 ${GIT_COMMIT}", returnStdout: true).trim()
GIT_USER = sh(script: "git log -1 --pretty=format:'%ae'", returnStdout: true).trim()
GITHUB_URL = "https://github.com"
LANG = "en_US.UTF-8"
LANGUAGE = "en_US:en"
LC_ALL = "en_US.UTF-8"
PRODUCTION_DEPLOY="false"
SLACK_CHANNEL = "#releases"
} // environment
agent {
kubernetes {
label k8s_label
defaultContainer 'jnlp'
yaml """
---
apiVersion: v1
kind: Pod
metadata:
name: test
spec:
restartPolicy: Never
containers:
- name: ruby
image: gcr.io/alist-development/ruby:2.7.5
imagePullPolicy: Always
resources:
requests:
memory: "1024Mi"
cpu: "1"
requests:
memory: "1024Mi"
cpu: "1"
command:
- "tail"
- "-f"
- "/dev/null"
"""
} // kubernetes
} // agent
options {
timestamps()
timeout(time: 10, unit: 'MINUTES')
ansiColor('xterm')
} // options
stages {
stage('Preparation') {
parallel {
stage('Slack') {
steps {
slackPreparation()
} // steps
} // stage - Slack
stage('Build Description') {
steps {
buildDescription()
}
}
stage('Bundle') {
steps {
withCredentials([usernamePassword(credentialsId: 'ApartmentList-CI', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_TOKEN')]) {
container('ruby') {
withEnv([
"GIT_USERNAME=${GIT_USERNAME}",
"GIT_TOKEN=${GIT_TOKEN}"
]) {
sh 'git config --global --add safe.directory $WORKSPACE'
sh 'gem install bundler:2.2.6 --no-post-install-message --no-document'
sh 'bundle config set --global rubygems.pkg.github.com $GIT_USERNAME:$GIT_TOKEN'
sh 'bundle install -j 12'
} // withEnv
} //container
} // withCredential
} //steps
} // stage - Bundle
} //parallel
} //stage - Preparation
stage('Testing') {
when {
allOf {
changeRequest target: 'main'
}
}
parallel {
stage('Run RSpec') {
steps {
container('ruby') {
sh label: 'RSpec', script: 'bundle exec rake'
} // container
} // steps
} // stage
} //parallel
} //stage
stage("Publish") {
when {
allOf {
branch "main"
not { changeRequest() }
}
} // when
parallel {
stage("to Github packages") {
steps {
publishRubyGemToGHP("ruby")
}
} // stage - to Github packages
} // parallel
} // stage - Publish
} // stages
post {
success {
success('alist-production')
} // success
aborted {
aborted('alist-production')
} // aborted
} // post
} // pipeline