Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): set owner of files created by containers to the local user #151

Merged
merged 1 commit into from
Jul 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious if this could be rewritten/simplified to:

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

... or would that last sh invocation not get run?

Copy link
Contributor Author

@Joshua-Anderson Joshua-Anderson Jul 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false kills the build, so it wouldn't run

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 @@ -51,9 +60,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 @@ -94,8 +103,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 @@ -110,8 +120,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 @@ -36,6 +36,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 @@ -107,3 +111,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} .