diff --git a/Jenkinsfile b/Jenkinsfile index 9a268376301c..78096a2aa991 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -526,13 +526,16 @@ pipeline { } } -def makeTarget(context, target){ +def makeTarget(context, target, clean = true){ withGithubNotify(context: "${context}") { withBeatsEnv(){ sh(label: "Make ${target}", script: """ eval "\$(gvm use ${GO_VERSION} --format=bash)" make ${target} """) + if(clean) { + sh(script: 'script/fix_permissions.sh ${HOME}') + } } } } diff --git a/libbeat/scripts/Makefile b/libbeat/scripts/Makefile index 69a9d95e7f4d..373b1a5e651e 100755 --- a/libbeat/scripts/Makefile +++ b/libbeat/scripts/Makefile @@ -421,8 +421,7 @@ env-logs: ${DOCKER_COMPOSE} logs -f fix-permissions: - # Change ownership of all files inside /build folder from root/root to current user/group - docker run -v ${PWD}:/beat alpine:3.4 sh -c "find /beat -user 0 -exec chown -h $(shell id -u):$(shell id -g) {} \;" + sh ${ES_BEATS}/script/fix_permissions.sh "${PWD}" set_version: ## @packaging VERSION=x.y.z set the version of the beat to x.y.z ${ES_BEATS}/dev-tools/set_version ${VERSION} diff --git a/script/fix_permissions.sh b/script/fix_permissions.sh new file mode 100755 index 000000000000..fd65a7916b50 --- /dev/null +++ b/script/fix_permissions.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set +e +readonly LOCATION="${1?Please define the path where the fix permissions should run from}" + +if ! docker version ; then + echo "It requires Docker daemon to be installed and running" +else + set -e + # Change ownership of all files inside the specific folder from root/root to current user/group + docker run -v ${LOCATION}:/beat alpine:3.4 sh -c "find /beat -user 0 -exec chown -h $(id -u):$(id -g) {} \;" +fi