-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Jenkinsfile
99 lines (91 loc) · 2.26 KB
/
Jenkinsfile
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
pipeline {
options {
timeout(time: 60, unit: 'MINUTES')
ansiColor('xterm')
disableConcurrentBuilds(abortPrevious: true)
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '5', numToKeepStr: '5')
}
agent {
label 'linux-arm64-docker || arm64linux'
}
environment {
INFRASTATISTICS_LOCATION = 'src/data/infra-statistics'
}
stages {
stage('Check for typos') {
steps {
sh 'typos --format json | typos-checkstyle - > checkstyle.xml || true'
}
post {
always {
recordIssues(tools: [checkStyle(id: 'typos', name: 'Typos', pattern: 'checkstyle.xml')])
}
}
}
stage('Install dependencies') {
steps {
sh '''
asdf install
npm install
'''
}
}
stage('Lint') {
steps {
sh '''
npm run lint
'''
}
}
stage('Retrieve data from infra-statistics') {
steps {
sh './retrieve-infra-statistics-data.sh'
}
}
stage('Build') {
steps {
sh '''
npm run build
'''
}
}
stage('Deploy to production') {
when {
allOf{
expression { env.BRANCH_IS_PRIMARY }
// Only deploy from infra.ci.jenkins.io
expression { infra.isInfra() }
}
}
steps {
script {
infra.withFileShareServicePrincipal([
servicePrincipalCredentialsId: 'infraci-stats-jenkins-io-fileshare-service-principal-writer',
fileShare: 'stats-jenkins-io',
fileShareStorageAccount: 'statsjenkinsio'
]) {
sh '''
# Synchronize the File Share content
set +x
azcopy sync \
--skip-version-check \
--recursive=true \
--delete-destination=true \
./dist/ "${FILESHARE_SIGNED_URL}"
'''
}
}
}
post {
failure {
// Only collect azcopy log when the deployment fails, because it is an heavy one
sh '''
# Retrieve azcopy logs to archive them
cat /home/jenkins/.azcopy/*.log > azcopy.log
'''
archiveArtifacts 'azcopy.log'
}
}
}
}
}