-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
40 lines (37 loc) · 1.25 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
String deduceDockerTag() {
String dockerTag = env.BRANCH_NAME
if (dockerTag.equals("main")) {
echo "Building the 'main' branch so we'll publish as the 'latest' Docker tag"
dockerTag = "latest"
} else {
dockerTag += env.BUILD_NUMBER
echo "Building a branch other than 'main' so will publish as $dockerTag, not 'latest'"
}
return dockerTag
}
pipeline {
agent {
label 'kaniko'
}
environment {
DOCKER_CRED = credentials('docker-hub-terasology-token')
DOCKER_TAG = deduceDockerTag()
}
stages {
stage('Build') {
steps {
container('kaniko') {
checkout scm
sh '''
set +x
tokenVar=$(echo -n $DOCKER_CRED | base64) > out.log 2>&1
sed -i "s/PLACEHOLDER/$tokenVar/g" config.json > out.log 2>&1
set -x
cp config.json /kaniko/.docker/config.json
/kaniko/executor -f ./Dockerfile -c $(pwd) --reproducible --destination=terasology/jenkins-android-agent:$DOCKER_TAG
'''
}
}
}
}
}