Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B536D200CF8 for ; Wed, 16 Aug 2017 01:10:21 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B4549167A3A; Tue, 15 Aug 2017 23:10:21 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0D812167A37 for ; Wed, 16 Aug 2017 01:10:20 +0200 (CEST) Received: (qmail 23117 invoked by uid 500); 15 Aug 2017 23:10:15 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 21865 invoked by uid 99); 15 Aug 2017 23:10:14 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Aug 2017 23:10:14 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 64961DFAFF; Tue, 15 Aug 2017 23:10:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bschuchardt@apache.org To: commits@geode.apache.org Date: Tue, 15 Aug 2017 23:10:45 -0000 Message-Id: <9de892fee8ff452b8e22d8fadddcb0db@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [34/50] [abbrv] geode git commit: GEODE-3423: Have Gradle set LOCAL_USER_ID archived-at: Tue, 15 Aug 2017 23:10:21 -0000 GEODE-3423: Have Gradle set LOCAL_USER_ID - This is needed because Jenkins' Gradle job doesn't seem to provide the ability to pass environment variables in. Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/d295876d Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/d295876d Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/d295876d Branch: refs/heads/feature/GEODE-3249 Commit: d295876d601300e52515193efcf5fd8549f10dbb Parents: a600068 Author: Jens Deppe Authored: Tue Aug 15 07:57:00 2017 -0700 Committer: Jens Deppe Committed: Tue Aug 15 07:57:00 2017 -0700 ---------------------------------------------------------------------- gradle/docker.gradle | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/d295876d/gradle/docker.gradle ---------------------------------------------------------------------- diff --git a/gradle/docker.gradle b/gradle/docker.gradle index d4828e4..b5a356f 100644 --- a/gradle/docker.gradle +++ b/gradle/docker.gradle @@ -38,6 +38,17 @@ * The default is 'root'. */ +static def getWorkingDirArgIndex(args) { + def index = 0 + for (arg in args) { + if (arg.equals('-w')) { + return index + 1 + } + index++ + } + return -1 +} + def dockerConfig = { maxParallelForks = dunitParallelForks.toInteger() @@ -76,17 +87,32 @@ def dockerConfig = { } // Remove JAVA_HOME and PATH env variables - they might not be the same as the container needs - args[javaHomeIdx] = 'JAVA_HOME_REMOVED=' - args[pathIdx] = 'PATH_REMOVED=' + if (javaHomeIdx > 0) { + args[javaHomeIdx] = 'JAVA_HOME_REMOVED=' + } + if (pathIdx > 0) { + args[pathIdx] = 'PATH_REMOVED=' + } + + // Unfortunately this snippet of code is here and is required by dev-tools/docker/base/entrypoint.sh. + // This allows preserving the outer user inside the running container. Required for Jenkins + // and other environments. There doesn't seem to be a way to pass this environment variable + // in from a Jenkins Gradle job. + if (System.env['LOCAL_USER_ID'] == null) { + def username = System.getProperty("user.name") + def uid = ['id', '-u', username].execute().text.trim() + args.add(1, "-e" as String) + args.add(2, "LOCAL_USER_ID=${uid}" as String) + } // Infer the index of this invocation def matcher = (args[args.size - 1] =~ /.*Executor (\d*).*/) - args[3] = args[3] + matcher[0][1] - def workdir = new File(args[3]) - // println "dockerize: making ${workdir}" + def pwdIndex = getWorkingDirArgIndex(args) + args[pwdIndex] = args[pwdIndex] + matcher[0][1] + def workdir = new File(args[pwdIndex]) workdir.mkdirs() - // println args +// println args args }