[JIRA] (JENKINS-50907) customWorkspace setting of agent directive does not support EXECUTOR_NUMBER

23 views
Skip to first unread message

c.amshoff@gmx.de (JIRA)

unread,
Apr 20, 2018, 5:49:02 AM4/20/18
to jenkinsc...@googlegroups.com
Christoph Amshoff created an issue
 
Jenkins / Bug JENKINS-50907
customWorkspace setting of agent directive does not support EXECUTOR_NUMBER
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline
Created: 2018-04-20 09:48
Priority: Critical Critical
Reporter: Christoph Amshoff

The default workspace has the executor number in the path, separated by '@' sign, for example c:\builds\jenkins-slave\workspace\test@2 when running on executor number 2.

This causes some trouble with our build scripts, so we'd like to use a path without '@' sign, but including the executor number (in order to isolate the builds). However, using something like
agent {
  node {
    label "myagent"
    customWorkspace("C:\\builds\\jenkins-slave\\workspace
${JOB_NAME}_${EXECUTOR_NUMBER}")
  }
}
does not work, it will issue a groovy.lang.MissingPropertyException: No such property: EXECUTOR_NUMBER.

Why can't EXECUTOR_NUMBER be used here? Any other way how this could be achieved?

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

c.amshoff@gmx.de (JIRA)

unread,
Apr 20, 2018, 5:50:01 AM4/20/18
to jenkinsc...@googlegroups.com
Christoph Amshoff updated an issue
Change By: Christoph Amshoff
The default workspace has the executor number in the path, separated by '@' sign, for example c:\builds\jenkins-slave\workspace\test@2 when running on executor number 2.

This causes some trouble with our build scripts, so we'd like to use a path without '@' sign, but including the executor number (in order to isolate the builds). However, using something like

{{
agent \{ }}
{{   node \{ }}
{{     label "myagent" }}
{{     customWorkspace ( "C:\\builds\\jenkins-slave\\workspace\\$\{JOB_NAME}_$\{EXECUTOR_NUMBER}" ) }}
{{   } }}
{{ } }}
{{ does not work, it will issue a groovy.lang.MissingPropertyException: No such property: EXECUTOR_NUMBER. }}

Why can't EXECUTOR_NUMBER be used here? Any other way how this could be achieved?

c.amshoff@gmx.de (JIRA)

unread,
Apr 20, 2018, 5:51:01 AM4/20/18
to jenkinsc...@googlegroups.com
Christoph Amshoff updated an issue
The default workspace has the executor number in the path, separated by '@' sign, for example c:\builds\jenkins-slave\workspace\test@2 when running on executor number 2.

This causes some trouble with our build scripts, so we'd like to use a path without '@' sign, but including the executor number (in order to isolate the builds). However, using something like

{ quote} { { agent \{}}
{{   node \{}}
{{     label "
myagent mu-s-lfbld5 "}}
{{     customWorkspace "C:\\builds\\jenkins-slave\\workspace\\$\{JOB_NAME}_$\{EXECUTOR_NUMBER}"}}
{{   }}}
{{ }}}

{ { quote}
does not work, it will issue a groovy.lang.MissingPropertyException: No such property: EXECUTOR_NUMBER.}}

Why can't EXECUTOR_NUMBER be used here? Any other way how this could be achieved?

c.amshoff@gmx.de (JIRA)

unread,
Apr 20, 2018, 5:53:02 AM4/20/18
to jenkinsc...@googlegroups.com
Christoph Amshoff updated an issue
The default workspace has the executor number in the path, separated by '@' sign, for example c:\builds\jenkins-slave\workspace\test@2 when running on executor number 2.

This causes some trouble with our build scripts, so we'd like to use a path without '@' sign, but including the executor number (in order to isolate the builds). However, using something like
{quote}agent \{
  node \{
    label "mu-s-lfbld5"

    customWorkspace "C:\\builds\\jenkins-slave\\workspace\\
\ $\{JOB_NAME}_$\{EXECUTOR_NUMBER}"

  }
}
{quote}
does not work, it will issue a groovy.lang.MissingPropertyException: No such property: EXECUTOR_NUMBER.}}

Why can't EXECUTOR_NUMBER be used here? Any other way how this could be achieved?

c.amshoff@gmx.de (JIRA)

unread,
Apr 20, 2018, 5:53:02 AM4/20/18
to jenkinsc...@googlegroups.com

c.amshoff@gmx.de (JIRA)

unread,
Apr 20, 2018, 5:54:02 AM4/20/18
to jenkinsc...@googlegroups.com
Christoph Amshoff updated an issue
The default workspace has the executor number in the path, separated by '@' sign, for example c:\builds\jenkins-slave\workspace\test@2 when running on executor number 2.

This causes some trouble with our build scripts, so we'd like to use a path without '@' sign, but including the executor number (in order to isolate the builds). However, using something like
{quote}agent \{
  node \{
    label "mu-s-lfbld5"
    customWorkspace "C:\\builds\\jenkins-slave\\workspace\\ \ job_ $\{JOB_NAME}_$\{EXECUTOR_NUMBER}"

  }
}
{quote}
does not work, it will issue a groovy.lang.MissingPropertyException: No such property: EXECUTOR_NUMBER.
}}

Why can't EXECUTOR_NUMBER be used here? Any other way how this could be achieved?

c.amshoff@gmx.de (JIRA)

unread,
Apr 20, 2018, 5:55:01 AM4/20/18
to jenkinsc...@googlegroups.com

c.amshoff@gmx.de (JIRA)

unread,
Apr 20, 2018, 5:56:02 AM4/20/18
to jenkinsc...@googlegroups.com
Christoph Amshoff updated an issue
The default workspace has the executor number in the path, separated by '@' sign, for example c:\builds\jenkins-slave\workspace\test@2 when running on executor number 2.

This causes some trouble with our build scripts, so we'd like to use a path without '@' sign, but including the executor number (in order to isolate the builds). However, using something like
{quote}agent \{
  node \{
    label "mu-s-lfbld5"
    customWorkspace "C:\builds\jenkins-slave\workspace\$\{JOB_NAME}_$\{EXECUTOR_NUMBER}"
  }
}
{quote}
in declarative pipeline does not work, it will issue a groovy.lang.MissingPropertyException: No such property: EXECUTOR_NUMBER.


Why can't EXECUTOR_NUMBER be used here? Any other way how this could be achieved?

c.amshoff@gmx.de (JIRA)

unread,
Apr 20, 2018, 5:56:02 AM4/20/18
to jenkinsc...@googlegroups.com
Christoph Amshoff updated an issue
The default workspace has the executor number in the path, separated by '@' sign, for example c:\builds\jenkins-slave\workspace\test@2 when running on executor number 2.

This causes some trouble with our build scripts, so we'd like to use a path without '@' sign, but including the executor number (in order to isolate the builds). However, using something like
{quote}agent \{
  node \{
    label " mu my - s-lfbld5 agent "

    customWorkspace "C:\builds\jenkins-slave\workspace\$\{JOB_NAME}_$\{EXECUTOR_NUMBER}"
  }
}
{quote}
in declarative pipeline does not work, it will issue a groovy.lang.MissingPropertyException: No such property: EXECUTOR_NUMBER.

Why can't EXECUTOR_NUMBER be used here? Any other way how this could be achieved?

andrew.bayer@gmail.com (JIRA)

unread,
Apr 24, 2018, 11:14:02 AM4/24/18
to jenkinsc...@googlegroups.com
Andrew Bayer updated an issue
Change By: Andrew Bayer
Component/s: pipeline-model-definition-plugin
Component/s: pipeline

andrew.bayer@gmail.com (JIRA)

unread,
Nov 7, 2018, 12:50:02 PM11/7/18
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-50907
 
Re: customWorkspace setting of agent directive does not support EXECUTOR_NUMBER

The problem here is that we generate the custom workspace string before we're actually on the agent. I'm not sure how we can work around that at this point - I'll think on it.

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

avnerht@gmail.com (JIRA)

unread,
Nov 13, 2018, 4:15:02 PM11/13/18
to jenkinsc...@googlegroups.com

This cause me also a problem - some of my tests are failing because of this @ symbol.

Maybe the approach should be a configuration of the separator - by default it can be @ but admin will be able to change it with other symbol like dash 

avnerht@gmail.com (JIRA)

unread,
Nov 14, 2018, 6:21:02 AM11/14/18
to jenkinsc...@googlegroups.com

for now i have an ugly workaround - set a soft link with _ instead of @

 

pipeline {

  stages {

        stage("set custom dir"){
            steps {
                script {
                    customDir=sh (returnStdout: true, script: 'set +e ; NEW_PWD=`pwd`; HAS_AT=`pwd | grep \\@` ; if [ "HAS_AT" != "" ]; then BAD_PWD=`pwd` ; NEW_PWD=`pwd | sed "s/\\@/_/"` ; if [ ! -e $NEW_PWD ]; then ln -s $BAD_PWD $NEW_PWD; fi  ; fi; echo $NEW_PWD').trim()
                }
            }
        }

        stage("demo the dir"){
            steps {
                dir (customDir) {
                    script {
                        sh "sleep 10 ; pwd"
                    }
                }
            }
        }
    }
}

def customDir

avnerht@gmail.com (JIRA)

unread,
Nov 14, 2018, 6:29:02 AM11/14/18
to jenkinsc...@googlegroups.com
Avner Hartuv edited a comment on Bug JENKINS-50907
for now i have an ugly workaround - set a soft link with _ instead of @

 
{code:java}

pipeline {

  stages {

        stage("set custom dir"){
            steps {
                script {
                    customDir=sh (returnStdout: true, script: 'set +e ;
\
NEW_PWD=`pwd`; \
HAS_AT=`pwd | grep \\@` ; \
if [ "HAS_AT" != "" ]; then \
BAD_PWD=`pwd` ; NEW_PWD=`pwd | sed "s/\\@/_/"` ; \
if [ ! -e $NEW_PWD ]; then \
ln -s $BAD_PWD $NEW_PWD; \
fi  ; \
fi; \
echo $NEW_PWD').trim()
                }
            }
        }

        stage("demo the dir"){
            steps {
                dir (customDir) {
                    script {
                     sh "sleep 10 ; pwd"
                    }
                }
            }
        }
    }
}

def customDir{code}

georgi.t.valkov@gmail.com (JIRA)

unread,
Jan 16, 2020, 9:34:08 AM1/16/20
to jenkinsc...@googlegroups.com

You can set the hudson.slaves.WorkspaceList system property to the separator that you'd like to use. For more information: https://wiki.jenkins.io/display/JENKINS/Features+controlled+by+system+properties

 

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

avnerht@gmail.com (JIRA)

unread,
Jan 16, 2020, 9:41:12 AM1/16/20
to jenkinsc...@googlegroups.com

c.amshoff@gmx.de (JIRA)

unread,
Jan 17, 2020, 7:24:05 AM1/17/20
to jenkinsc...@googlegroups.com

Georgi, thanks for your input!

According to mentioned web page, this property is already available since version 1.424. I wish we had gotten this information ealier, would have saved us quite some time...

c.amshoff@gmx.de (JIRA)

unread,
Jan 17, 2020, 7:25:06 AM1/17/20
to jenkinsc...@googlegroups.com
Christoph Amshoff closed an issue as Fixed
 

Setting system property hudson.slaves.WorkspaceList should do the trick, see https://wiki.jenkins.io/display/JENKINS/Features+controlled+by+system+properties

Change By: Christoph Amshoff
Status: Open Closed
Resolution: Fixed
Reply all
Reply to author
Forward
0 new messages