Skip to content

Commit 89e4177

Browse files
fix(tests): set owner of files created by containers to the local user (#151)
1 parent 072ef30 commit 89e4177

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

Jenkinsfile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@ def getBasePath = { String filepath ->
66
return filepath.substring(0, filename)
77
}
88

9+
def make = { String target ->
10+
try {
11+
sh "make ${target} fileperms"
12+
} catch(error) {
13+
sh "make fileperms"
14+
false
15+
}
16+
}
17+
918
def upload_artifacts = { String filepath ->
1019
withCredentials([[$class: 'FileBinding', credentialsId: 'e80fd033-dd76-4d96-be79-6c272726fb82', variable: 'GCSKEY']]) {
1120
sh "mkdir -p ${getBasePath(filepath)}"
1221
sh "cat \"\${GCSKEY}\" > ${filepath}"
13-
sh "make upload-gcs"
22+
make 'upload-gcs'
1423
}
1524
}
1625

@@ -57,9 +66,9 @@ node('linux') {
5766
stage 'Checkout Linux'
5867
checkout scm
5968
stage 'Install Linux'
60-
sh 'make bootstrap'
69+
make 'bootstrap'
6170
stage 'Test Linux'
62-
sh 'make test'
71+
make 'test'
6372
}
6473
}
6574

@@ -100,8 +109,9 @@ parallel(
100109
env.BUILD_ARCH = "amd64"
101110
}
102111

103-
sh 'make bootstrap'
104-
sh "VERSION=${git_commit.take(7)} make build-revision"
112+
make 'bootstrap'
113+
env.VERSION = git_commit.take(7)
114+
make 'build-revision'
105115

106116
upload_artifacts(keyfile)
107117
}
@@ -116,8 +126,8 @@ parallel(
116126
checkout scm
117127

118128
if (git_branch == "remotes/origin/master") {
119-
sh 'make bootstrap'
120-
sh 'make build-latest'
129+
make 'bootstrap'
130+
make 'build-latest'
121131

122132
upload_artifacts(keyfile)
123133
} else {

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ GOTEST = go test --cover --race -v
3434
GIT_TAG := $(shell git tag -l --contains HEAD)
3535
VERSION ?= $(shell git rev-parse --short HEAD)
3636

37+
# UID and GID of local user
38+
UID := $(shell id -u)
39+
GID := $(shell id -g)
40+
3741
define check-static-binary
3842
if file $(1) | egrep -q "(statically linked|Mach-O)"; then \
3943
echo -n ""; \
@@ -105,3 +109,7 @@ upload-gcs:
105109
${GSUTIL_CMD} sh -c 'gsutil -mq cp -a public-read -r /upload/* ${GCS_BUCKET}'
106110
# This has to run in the container to delete files created by the container
107111
${GSUTIL_CMD} sh -c 'rm -rf /.config/*'
112+
113+
# Set local user as owner for files
114+
fileperms:
115+
${DEV_ENV_PREFIX_CGO_ENABLED} ${DEV_ENV_IMAGE} chown -R ${UID}:${GID} .

0 commit comments

Comments
 (0)