-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathJenkinsfile
34 lines (33 loc) · 1.23 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
podTemplate(label: 'academy-builder', containers: [
containerTemplate(name: 'docker', image: 'docker', ttyEnabled: true, command: 'cat', envVars: [
envVar(key: 'DOCKER_HOST', value: 'tcp://docker-host-docker-host:2375')
])
]) {
node('academy-builder') {
stage('Build') {
container('docker') {
def scmVars = checkout scm
def gitHead = scmVars.GIT_COMMIT.substring(0,7)
if (env.BRANCH_NAME == "master") {
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 -t ${awsRegistry}/academy:${env.BRANCH_NAME} -t ${awsRegistry}/academy:${scmVars.GIT_COMMIT} ."
sh "docker push ${awsRegistry}/academy:${env.BRANCH_NAME}"
sh "docker push ${awsRegistry}/academy:${scmVars.GIT_COMMIT}"
}
}
}
}
}
}
}