-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
129 lines (121 loc) · 4.13 KB
/
Jenkinsfile
File metadata and controls
129 lines (121 loc) · 4.13 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
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.6'
pipeline {
agent {
docker {
label 'linuxcontainer'
image 'harbor.status.im/infra/ci-build-containers:linux-base-1.0.0'
args '--volume=/var/run/docker.sock:/var/run/docker.sock ' +
'--user jenkins'
}
}
parameters {
string(
name: 'IMAGE_TAG',
defaultValue: params.IMAGE_TAG ?: '',
description: 'Optional Docker image tag to push.'
)
string(
name: 'STRAPI_API_URL',
description: 'URL of Strapi API',
defaultValue: params.STRAPI_API_URL ?: 'https://cms-press.logos.co/api',
)
string(
name: 'STRAPI_GRAPHQL_URL',
description: 'URL of Strapi GraphQL API',
defaultValue: params.STRAPI_GRAPHQL_URL ?: 'https://cms-press.logos.co/graphql',
)
string(
name: 'NEXT_PUBLIC_ASSETS_BASE_URL',
description: 'URL for public assets',
defaultValue: params.NEXT_PUBLIC_ASSETS_BASE_URL ?: 'https://cms-press.logos.co',
)
string(
name: 'NEXT_PUBLIC_ADMIN_ACID_API_URL',
description: 'URL of Admin Acid API',
defaultValue: params.NEXT_PUBLIC_ADMIN_ACID_API_URL ?: 'https://dev-admin-acid.logos.co/api',
)
string(
name: 'DOCKER_REGISTRY',
description: 'Docker registry ',
defaultValue: params.DOCKER_REGISTRY ?: 'harbor.status.im',
)
}
options {
disableRestartFromStage()
disableConcurrentBuilds()
/* manage how many builds we keep */
buildDiscarder(logRotator(
numToKeepStr: '20',
daysToKeepStr: '30',
))
}
environment {
IMAGE_NAME = 'acid-info-private/logos-press-engine'
}
stages {
stage('Build') {
steps {
script {
def adminAcidApiUrl = (GIT_BRANCH.endsWith('master'))
? 'https://admin-acid.logos.co/api'
: params.NEXT_PUBLIC_ADMIN_ACID_API_URL
withCredentials([
usernamePassword(
credentialsId: 'logos-press-engine-unbody-api-token',
usernameVariable: 'UNBODY_PROJECT_ID',
passwordVariable: 'UNBODY_API_KEY'
),
string(
credentialsId: 'logos-press-engine-simplecast-token',
variable: 'SIMPLECAST_ACCESS_TOKEN'
),
string(
credentialsId: 'logos-press-engine-webhook-token',
variable: 'REVALIDATE_WEBHOOK_TOKEN'
),
string(
credentialsId: 'logos-press-engine-strapi-api-key',
variable: 'STRAPI_API_KEY'
),
]) {
image = docker.build(
"${DOCKER_REGISTRY}/${IMAGE_NAME}:${GIT_COMMIT.take(8)}",
["--build-arg='STRAPI_API_KEY=${env.UNBODY_PROJECT_ID}'",
"--build-arg='UNBODY_API_KEY=${env.UNBODY_API_KEY}'",
"--build-arg='SIMPLECAST_ACCESS_TOKEN=${SIMPLECAST_ACCESS_TOKEN}'",
"--build-arg='REVALIDATE_WEBHOOK_TOKEN=${REVALIDATE_WEBHOOK_TOKEN}'",
"--build-arg='STRAPI_API_URL=${params.STRAPI_API_URL}'",
"--build-arg='STRAPI_GRAPHQL_URL=${params.STRAPI_GRAPHQL_URL}'",
"--build-arg='NEXT_PUBLIC_ASSETS_BASE_URL=${params.NEXT_PUBLIC_ASSETS_BASE_URL}'",
"--build-arg='NEXT_PUBLIC_ADMIN_ACID_API_URL=${adminAcidApiUrl}'",
"--build-arg='STRAPI_API_KEY=${STRAPI_API_KEY}'",
"."].join(' ')
)
}
}
}
}
stage('Deploy') {
when { expression { params.IMAGE_TAG != '' } }
steps { script {
withDockerRegistry([
credentialsId: 'harbor-acid-info-private-robot', url: "https://${DOCKER_REGISTRY}"
]) {
image.push(params.IMAGE_TAG)
}
} }
}
}
post {
cleanup { cleanWs() }
always { script {
def result = currentBuild.result.toLowerCase() ?: 'unknown'
discord.send(
header: "Logos Press Engine Docker image build ${result}!",
descPrefix: "Image: [`${env.IMAGE_NAME}:${params.IMAGE_TAG}`](https://harbor.status.im/${params.IMAGE_NAME}/tags?name=${params.IMAGE_TAG})",
cred: 'logos-press-engine-discord-webhook-url',
)
} }
}
}