1#!groovy
2
3
4def genBranch(String arch) {
5	return [
6		"${arch}": { ->
7			stage("Build engine image on ${arch}") {
8				wrappedNode(label: "linux&&${arch}", cleanWorkspace: true) {
9					try {
10						checkout scm
11						sh("git clone https://github.com/docker/engine.git engine")
12						sh('make ENGINE_DIR=$(pwd)/engine image')
13					} finally {
14						sh('make ENGINE_DIR=$(pwd)/engine clean-image clean-engine')
15					}
16				}
17		}
18	}]
19}
20
21def branch = env.CHANGE_TARGET ?: env.BRANCH_NAME
22
23test_steps = [
24	'deb': { ->
25		stage('Ubuntu Xenial Debian Package') {
26			wrappedNode(label: 'ubuntu && x86_64', cleanWorkspace: true) {
27				checkout scm
28				sh('git clone https://github.com/docker/cli.git')
29				sh("git -C cli checkout $branch")
30				sh('git clone https://github.com/docker/engine.git')
31				sh("git -C engine checkout $branch")
32				sh('make VERSION=0.0.1-dev DOCKER_BUILD_PKGS=ubuntu-xenial ENGINE_DIR=$(pwd)/engine CLI_DIR=$(pwd)/cli deb')
33			}
34		}
35	},
36	'rpm': { ->
37		stage('Centos 7 RPM Package') {
38			wrappedNode(label: 'ubuntu && x86_64', cleanWorkspace: true) {
39				checkout scm
40				sh('git clone https://github.com/docker/cli.git')
41				sh("git -C cli checkout $branch")
42				sh('git clone https://github.com/docker/engine.git')
43				sh("git -C engine checkout $branch")
44				sh('make VERSION=0.0.1-dev DOCKER_BUILD_PKGS=centos-7 ENGINE_DIR=$(pwd)/engine CLI_DIR=$(pwd)/cli rpm')
45			}
46		}
47	},
48	'static': { ->
49		stage('Static Linux Binaries') {
50			wrappedNode(label: 'ubuntu && x86_64', cleanWorkspace: true) {
51				checkout scm
52				sh('git clone https://github.com/docker/cli.git')
53				sh("git -C cli checkout $branch")
54				sh('git clone https://github.com/docker/engine.git')
55				sh("git -C engine checkout $branch")
56				sh('make VERSION=0.0.1-dev DOCKER_BUILD_PKGS=static-linux ENGINE_DIR=$(pwd)/engine CLI_DIR=$(pwd)/cli static')
57			}
58		}
59	},
60]
61
62arches = [
63	"x86_64",
64	// "s390x",
65	"ppc64le",
66	"aarch64",
67	"armhf"
68]
69
70arches.each {
71	test_steps << genBranch(it)
72}
73
74parallel(test_steps)
75