Jenkinsfile: yet another attempt to calculate uid and gid of the workspace

Project: http://git-wip-us.apache.org/repos/asf/logging-log4net/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4net/commit/ad7dbc03
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4net/tree/ad7dbc03
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4net/diff/ad7dbc03

Branch: refs/heads/feature/RollingFileAppender-NG
Commit: ad7dbc03f584ee1a6647e5c1ff98fef396bf83c7
Parents: 86ddc07
Author: Dominik Psenner <dpsen...@apache.org>
Authored: Tue Jul 18 11:00:48 2017 +0200
Committer: Dominik Psenner <dpsen...@apache.org>
Committed: Tue Jul 18 11:00:48 2017 +0200

----------------------------------------------------------------------
 Jenkinsfile | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/ad7dbc03/Jenkinsfile
----------------------------------------------------------------------
diff --git a/Jenkinsfile b/Jenkinsfile
index 385982f..953d94e 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -32,10 +32,16 @@ pipeline {
                        steps {
                                deleteDir()
                                checkout scm
-                               sh 'export JENKINS_UID="$(stat -c \"%u\" .)"'
-                               sh 'export JENKINS_GID="$(stat -c \"%g\" .)"'
-                               sh 'echo $JENKINS_UID'
-                               sh 'echo $JENKINS_GID'
+                               env.JENKINS_UID=sh (
+                                       script: 'stat -c "%u" ${env.WORKSPACE}'
+                                       returnStdout: true
+                               )
+                               env.JENKINS_GID=sh (
+                                       script: 'stat -c "%g" ${env.WORKSPACE}'
+                                       returnStdout: true
+                               )
+                               sh 'echo ${env.JENKINS_UID}'
+                               sh 'echo ${env.JENKINS_GID}'
                        }
                }
 
@@ -44,14 +50,14 @@ pipeline {
                        agent {
                                dockerfile {
                                        dir 
'buildtools/docker/builder-netstandard'
-                                       args "--build-arg 
JENKINS_UID=$JENKINS_UID --build-arg JENKINS_GID=$JENKINS_GID"
+                                       args '--build-arg 
JENKINS_UID=${env.JENKINS_UID} --build-arg JENKINS_GID=${env.JENKINS_GID}'
                                        reuseNode true
                                }
                        }
-                       environment {
-                               WORKSPACE = '/var/workspaces/jenkins'
-                       }
                        steps {
+                               sh 'echo ${env.JENKINS_UID}'
+                               sh 'echo ${env.JENKINS_GID}'
+
                                checkout scm
 
                                // compile 

Reply via email to