forked from alisw/docks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
57 lines (51 loc) · 1.85 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
#!groovy
node("docker-light") {
stage "Verify author"
def power_users = ["ktf", "dberzano"]
def deployable_branches = ["master"]
echo "Changeset from " + env.CHANGE_AUTHOR
if (power_users.contains(env.CHANGE_AUTHOR)) {
echo "PR comes from power user. Testing"
} else if(deployable_branches.contains(env.BRANCH_NAME)) {
echo "Building master branch."
} else {
input "Do you want to test this change?"
}
stage "Build containers"
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
withEnv([ "BRANCH_NAME=${env.BRANCH_NAME}",
"CHANGE_TARGET=${env.CHANGE_TARGET}"]) {
dir ("docks") {
withCredentials([[$class: 'UsernamePasswordMultiBinding',
credentialsId: '75206d40-8dcf-4f44-aea4-e3a32bc201b3',
usernameVariable: 'DOCK_USER',
passwordVariable: 'DOCK_PASSWORD']]) {
retry(2) {
timeout(900) {
checkout scm
sh '''
set -e
set -o pipefail
packer version
GIT_DIFF_SRC="origin/$CHANGE_TARGET"
[[ $CHANGE_TARGET == null || -z $CHANGE_TARGET ]] && GIT_DIFF_SRC="HEAD^"
case $BRANCH_NAME in
master) DEVMODE= ;;
*) DEVMODE=dev ;;
esac
export PACKER_LOG=1
export PACKER_LOG_PATH=$PWD/packer.log
mkdir -p /build/packer && [[ -d /build/packer ]]
export TMPDIR=$(mktemp -d /build/packer/packer-XXXXX)
export HOME=$TMPDIR
yes | docker login -u "$DOCK_USER" -p "$DOCK_PASSWORD" || true
unset DOCK_USER DOCK_PASSWORD
make DEVMODE=$DEVMODE
'''
}
}
}
}
}
}
}