forked from jenkins-infra/docs.jenkins.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
100 lines (94 loc) · 2.68 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
100
pipeline {
options {
timeout(time: 60, unit: 'MINUTES')
ansiColor('xterm')
disableConcurrentBuilds(abortPrevious: true)
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '5', numToKeepStr: '5')
}
agent {
label 'linux-arm64 || arm64linux'
}
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') {
environment {
NODE_ENV = 'development'
}
steps {
sh '''
asdf install
npm install
npm run install-subfolders
'''
}
}
stage('Build') {
steps {
sh '''
npm run build-ui
npm run build-antora
'''
}
}
stage('Deploy PR to preview site') {
when {
allOf{
changeRequest target: 'main'
// Only deploy from infra.ci.jenkins.io
expression { infra.isInfra() }
}
}
environment {
NETLIFY_AUTH_TOKEN = credentials('netlify-auth-token')
}
steps {
sh 'netlify-deploy --draft=true --siteName "docs-jenkins-io" --title "Preview deploy for ${CHANGE_ID}" --alias "deploy-preview-${CHANGE_ID}" -d ./playbook/build/site'
}
post {
success {
recordDeployment('jenkins-infra', 'docs.jenkins.io', pullRequest.head, 'success', "https://deploy-preview-${CHANGE_ID}--docs-jenkins-io.netlify.app")
}
failure {
recordDeployment('jenkins-infra', 'docs.jenkins.io', pullRequest.head, 'failure', "https://deploy-preview-${CHANGE_ID}--docs-jenkins-io.netlify.app")
}
}
}
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-docs-jenkins-io-fileshare-service-principal-writer',
fileShare: 'docs-jenkins-io',
fileShareStorageAccount: 'docsjenkinsio'
]) {
sh '''
# Synchronize the File Share content
set +x
azcopy sync \
--skip-version-check \
--recursive=true \
--delete-destination=true \
./playbook/build/site/ "${FILESHARE_SIGNED_URL}"
'''
}
}
}
}
}
}