Skip to content

Commit

Permalink
fix(tests): set owner of files created by containers to the local user (
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Anderson committed Jul 27, 2016
1 parent 072ef30 commit 89e4177
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
24 changes: 17 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ def getBasePath = { String filepath ->
return filepath.substring(0, filename)
}

def make = { String target ->
try {
sh "make ${target} fileperms"
} catch(error) {
sh "make fileperms"
false
}
}

def upload_artifacts = { String filepath ->
withCredentials([[$class: 'FileBinding', credentialsId: 'e80fd033-dd76-4d96-be79-6c272726fb82', variable: 'GCSKEY']]) {
sh "mkdir -p ${getBasePath(filepath)}"
sh "cat \"\${GCSKEY}\" > ${filepath}"
sh "make upload-gcs"
make 'upload-gcs'
}
}

Expand Down Expand Up @@ -57,9 +66,9 @@ node('linux') {
stage 'Checkout Linux'
checkout scm
stage 'Install Linux'
sh 'make bootstrap'
make 'bootstrap'
stage 'Test Linux'
sh 'make test'
make 'test'
}
}

Expand Down Expand Up @@ -100,8 +109,9 @@ parallel(
env.BUILD_ARCH = "amd64"
}

sh 'make bootstrap'
sh "VERSION=${git_commit.take(7)} make build-revision"
make 'bootstrap'
env.VERSION = git_commit.take(7)
make 'build-revision'

upload_artifacts(keyfile)
}
Expand All @@ -116,8 +126,8 @@ parallel(
checkout scm

if (git_branch == "remotes/origin/master") {
sh 'make bootstrap'
sh 'make build-latest'
make 'bootstrap'
make 'build-latest'

upload_artifacts(keyfile)
} else {
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ GOTEST = go test --cover --race -v
GIT_TAG := $(shell git tag -l --contains HEAD)
VERSION ?= $(shell git rev-parse --short HEAD)

# UID and GID of local user
UID := $(shell id -u)
GID := $(shell id -g)

define check-static-binary
if file $(1) | egrep -q "(statically linked|Mach-O)"; then \
echo -n ""; \
Expand Down Expand Up @@ -105,3 +109,7 @@ upload-gcs:
${GSUTIL_CMD} sh -c 'gsutil -mq cp -a public-read -r /upload/* ${GCS_BUCKET}'
# This has to run in the container to delete files created by the container
${GSUTIL_CMD} sh -c 'rm -rf /.config/*'

# Set local user as owner for files
fileperms:
${DEV_ENV_PREFIX_CGO_ENABLED} ${DEV_ENV_IMAGE} chown -R ${UID}:${GID} .

0 comments on commit 89e4177

Please sign in to comment.