Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 5fbad80

Browse files
authored
Merge pull request #44 from mat007/windows-build
Windows build
2 parents 6c930d1 + 5cca44d commit 5fbad80

File tree

2 files changed

+83
-27
lines changed

2 files changed

+83
-27
lines changed

Jenkinsfile

Lines changed: 70 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,75 @@
11
properties([buildDiscarder(logRotator(numToKeepStr: '20'))])
22

3-
node('gcp-linux-worker-0') {
4-
stage('Build') {
5-
dir('src/github.com/docker/lunchbox') {
6-
try {
7-
checkout scm
8-
sh 'rm -f *.tar.gz'
9-
sh 'docker image prune -f'
10-
sh 'make ci-lint'
11-
sh 'make ci-test'
12-
sh 'make ci-bin-linux'
13-
sh 'make ci-bin-darwin'
14-
sh 'make ci-bin-windows'
15-
archiveArtifacts '*.tar.gz'
16-
} finally {
17-
def clean_images = /docker image ls --format "{{.ID}}\t{{.Tag}}" | grep $(git describe --always --dirty) | awk '{print $1}' | xargs docker image rm/
18-
sh clean_images
3+
pipeline {
4+
agent {
5+
label 'gcp-linux-worker-0'
6+
}
7+
8+
options {
9+
checkoutToSubdirectory('src/github.com/docker/lunchbox')
10+
}
11+
12+
stages {
13+
stage('Build') {
14+
agent {
15+
label 'gcp-linux-worker-0'
16+
}
17+
steps {
18+
dir('src/github.com/docker/lunchbox') {
19+
script {
20+
try {
21+
checkout scm
22+
sh 'rm -f *.tar.gz'
23+
sh 'docker image prune -f'
24+
sh 'make ci-lint'
25+
sh 'make ci-test'
26+
sh 'make ci-bin-all'
27+
sh 'ls *.tar.gz | xargs -i tar xf {}'
28+
stash name: "binaries", includes: "docker-app-*", excludes: "*.tar.gz"
29+
archiveArtifacts '*.tar.gz'
30+
} finally {
31+
def clean_images = /docker image ls --format "{{.ID}}\t{{.Tag}}" | grep $(git describe --always --dirty) | awk '{print $1}' | xargs docker image rm/
32+
sh clean_images
33+
}
34+
}
35+
}
36+
}
37+
}
38+
stage('Test') {
39+
parallel {
40+
stage("Test Linux") {
41+
agent {
42+
label 'gcp-linux-worker-0'
43+
}
44+
steps {
45+
dir('src/github.com/docker/lunchbox') {
46+
unstash "binaries"
47+
sh './docker-app-linux version'
48+
}
49+
}
50+
}
51+
stage("Test Mac") {
52+
agent {
53+
label "macstadium13"
54+
}
55+
steps {
56+
dir('src/github.com/docker/lunchbox') {
57+
unstash "binaries"
58+
sh './docker-app-darwin version'
59+
}
60+
}
61+
}
62+
stage("Test Win") {
63+
agent {
64+
label "gcp-windows-worker-2"
65+
}
66+
steps {
67+
dir('src/github.com/docker/lunchbox') {
68+
unstash "binaries"
69+
bat 'docker-app-windows.exe version'
70+
}
71+
}
72+
}
1973
}
2074
}
2175
}

Makefile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ LDFLAGS := "-s -w \
2424
-X $(PKG_NAME)/internal.Version=$(TAG) \
2525
-X $(PKG_NAME)/internal.Experimental=$(EXPERIMENTAL)"
2626

27+
GO_BUILD := CGO_ENABLED=0 go build
28+
GO_TEST := go test
29+
2730
#####################
2831
# Local Development #
2932
#####################
@@ -35,18 +38,18 @@ endif
3538

3639
all: bin test
3740

38-
CHECK_GO_ENV:
41+
check_go_env:
3942
@test $$(go list) = "$(PKG_NAME)" || \
4043
(echo "Invalid Go environment" && false)
4144

42-
bin: CHECK_GO_ENV
45+
bin: check_go_env
4346
@echo "Building _build/$(BIN_NAME)$(EXEC_EXT)..."
44-
go build -ldflags=$(LDFLAGS) -i -o _build/$(BIN_NAME)$(EXEC_EXT)
47+
$(GO_BUILD) -ldflags=$(LDFLAGS) -i -o _build/$(BIN_NAME)$(EXEC_EXT)
4548

4649
OS_LIST ?= darwin linux windows
47-
bin-all: CHECK_GO_ENV
50+
bin-all: check_go_env
4851
@echo "Building for all platforms..."
49-
$(foreach OS, $(OS_LIST), GOOS=$(OS) go build -ldflags=$(LDFLAGS) -i -o _build/$(TAG)/$(BIN_NAME)-$(OS)$(if $(filter windows, $(OS)),.exe,) || exit 1;)
52+
$(foreach OS, $(OS_LIST), GOOS=$(OS) $(GO_BUILD) -ldflags=$(LDFLAGS) -i -o _build/$(TAG)/$(BIN_NAME)-$(OS)$(if $(filter windows, $(OS)),.exe,) || exit 1;)
5053

5154
release:
5255
gsutil cp -r _build/$(TAG) gs://docker_app
@@ -60,11 +63,11 @@ lint:
6063

6164
e2e-test: bin
6265
@echo "Running e2e tests..."
63-
go test ./e2e/
66+
$(GO_TEST) ./e2e/
6467

6568
unit-test:
6669
@echo "Running unit tests..."
67-
go test $(shell go list ./... | grep -vE '/vendor/|/e2e')
70+
$(GO_TEST) $(shell go list ./... | grep -vE '/vendor/|/e2e')
6871

6972
clean:
7073
rm -Rf ./_build docker-app-*.tar.gz
@@ -82,10 +85,9 @@ ci-test:
8285
@echo "Testing..."
8386
docker build -t $(IMAGE_NAME)-test:$(TAG) $(IMAGE_BUILD_ARGS) . --target=test
8487

85-
ci-bin-%:
86-
@echo "Building tarball for $*..."
88+
ci-bin-all:
8789
docker build -t $(IMAGE_NAME)-bin-all:$(TAG) $(IMAGE_BUILD_ARGS) . --target=bin-build
88-
docker run --rm $(IMAGE_NAME)-bin-all:$(TAG) tar -cz $(BIN_NAME)-$*$(if $(filter windows, $*),.exe,) -C /go/src/$(PKG_NAME)/_build/$(TAG)/ > $(BIN_NAME)-$*-$(TAG).tar.gz
90+
$(foreach OS, $(OS_LIST), docker run --rm $(IMAGE_NAME)-bin-all:$(TAG) tar -cz $(BIN_NAME)-$(OS)$(if $(filter windows, $(OS)),.exe,) -C /go/src/$(PKG_NAME)/_build/$(TAG)/ > $(BIN_NAME)-$(OS)-$(TAG).tar.gz || exit 1;)
8991

90-
.PHONY: bin bin-all release test check lint e2e-test unit-test clean ci-lint ci-test
92+
.PHONY: bin bin-all release test check lint e2e-test unit-test clean ci-lint ci-test ci-bin-all
9193
.DEFAULT: all

0 commit comments

Comments
 (0)