-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
63 lines (55 loc) · 2.41 KB
/
Jenkinsfile
File metadata and controls
63 lines (55 loc) · 2.41 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
@Library('podTemplateLib')
import net.santiment.utils.podTemplates
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: ''))])
slaveTemplates = new podTemplates()
slaveTemplates.dockerTemplate { label ->
node(label) {
stage('Build') {
container('docker') {
def scmVars = checkout scm
if (env.BRANCH_NAME == "main") {
def backendUrl = "https://api-stage.santiment.net"
def siteUrl = "https://santimentnet-stage.santiment.net"
withCredentials([
string(
credentialsId: 'SECRET_KEY_BASE',
variable: 'SECRET_KEY_BASE'
),
string(
credentialsId: 'aws_account_id',
variable: 'aws_account_id'
)
]) {
def awsRegistry = "${env.aws_account_id}.dkr.ecr.eu-central-1.amazonaws.com"
docker.withRegistry("https://${awsRegistry}", "ecr:eu-central-1:ecr-credentials") {
sh "docker build --build-arg BACKEND_URL=${backendUrl} --build-arg SITE_URL=${siteUrl} -t ${awsRegistry}/santimentnet:${env.BRANCH_NAME} -t ${awsRegistry}/santimentnet:${scmVars.GIT_COMMIT} ."
sh "docker push ${awsRegistry}/santimentnet:${env.BRANCH_NAME}"
sh "docker push ${awsRegistry}/santimentnet:${scmVars.GIT_COMMIT}"
}
}
}
if (env.BRANCH_NAME == "production") {
def backendUrl = "https://api.santiment.net"
def siteUrl = "https://santiment.net"
withCredentials([
string(
credentialsId: 'SECRET_KEY_BASE',
variable: 'SECRET_KEY_BASE'
),
string(
credentialsId: 'aws_account_id',
variable: 'aws_account_id'
)
]) {
def awsRegistry = "${env.aws_account_id}.dkr.ecr.eu-central-1.amazonaws.com"
docker.withRegistry("https://${awsRegistry}", "ecr:eu-central-1:ecr-credentials") {
sh "docker build --build-arg BACKEND_URL=${backendUrl} --build-arg SITE_URL=${siteUrl} -t ${awsRegistry}/santimentnet:production -t ${awsRegistry}/santimentnet:${scmVars.GIT_COMMIT} ."
sh "docker push ${awsRegistry}/santimentnet:production"
sh "docker push ${awsRegistry}/santimentnet:${scmVars.GIT_COMMIT}"
}
}
}
}
}
}
}