Re: No workspace variable during workflow / pipeline build?

2016-11-03 Thread Jesse Glick
A subsequent plugin update does in fact define the environment variable 
`WORKSPACE`. But yes you could always use `pwd()` instead.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/7c7bcbce-5193-4d57-9b34-c473a7754aaf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: No workspace variable during workflow / pipeline build?

2016-01-27 Thread David Karlsen
Yes - that's what I ended with - I was a bit dim in the start not really 
reasoning over what WORKSPACE really is.
Thanks a lot for your time and answer!

onsdag 27. januar 2016 20.20.25 UTC+1 skrev Craig Rodrigues følgende:
>
> Hi,
>
> You could also work around this by doing:
>
> node() {
> workspace = pwd()
>// rest of code here
> }
>
> See: 
> https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy
>
> for an example.
> --
> Craig
>
> On Wed, Jan 27, 2016 at 10:49 AM, Eric Pyle  > wrote:
>
>> Workaround:
>>
>> sh 'pwd > pwd.txt'
>> workspace = readFile('pwd.txt')
>>
>>
>> On 1/27/2016 1:15 PM, Eric Pyle wrote:
>>
>> WORKSPACE is documented as not being available in workflow/pipeline 
>> scripts. I found this when you select "env" under Global Variables in the 
>> snippet generator:
>>
>> The following variables are currently unavailable inside a workflow 
>> script:
>>
>>- EXECUTOR_NUMBER 
>>- NODE_LABELS 
>>- WORKSPACE 
>>- SCM-specific variables such as SVN_REVISION 
>>
>>
>>
>> On 1/27/2016 4:14 AM, David Karlsen wrote:
>>
>> I have this build definition: 
>>
>> node ('docker') {
>>   wrap([$class: 'TimestamperBuildWrapper']) {
>> stage 'checkout'
>> checkout scm: [$class: 'GitSCM', branches: [[name: '*/develop']], 
>> userRemoteConfigs: [[url: ' ssh:...@myserver:port/myrepo.git 
>> ']]]
>>
>> stage 'unit-test'
>> env.JAVA_HOME="${tool 'Oracle-JDK8-64bit'}"
>> def mvnHome = tool 'apache-maven-3.x'
>> def workSpace = env.WORKSPACE
>> def mvnCmd = "${mvnHome}/bin/mvn -B 
>> -Dmaven.repo.local=${workSpace}/.m2"
>> echo "workspace: ${workSpace} mvnCmd: ${mvnCmd}"
>> sh "${mvnCmd}/bin/mvn -B clean install"
>> 
>>
>>
>>
>>
>> But workspace is null:
>>
>> Running: Print Message*08:55:38* *workspace: null* mvnCmd: 
>> /var/lib/jenkins/tools/maven/apache-maven-3.x/bin/mvn -B 
>> -Dmaven.repo.local=null/.m2
>>
>>
>> Should it not be assigned to the env.WORKSPACE var by default?
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jenkinsci-use...@googlegroups.com .
>> To view this discussion on the web visit 
>> 
>> https://groups.google.com/d/msgid/jenkinsci-users/5d2f08e0-f692-4b6e-a657-dbb5bc66a251%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jenkinsci-use...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/56A9114F.8080909%40cd-adapco.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/1ee35c16-f449-4136-a30a-4e5dc0e370f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: No workspace variable during workflow / pipeline build?

2016-01-27 Thread Craig Rodrigues
Hi,

You could also work around this by doing:

node() {
workspace = pwd()
   // rest of code here
}

See:
https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy

for an example.
--
Craig

On Wed, Jan 27, 2016 at 10:49 AM, Eric Pyle  wrote:

> Workaround:
>
> sh 'pwd > pwd.txt'
> workspace = readFile('pwd.txt')
>
>
> On 1/27/2016 1:15 PM, Eric Pyle wrote:
>
> WORKSPACE is documented as not being available in workflow/pipeline
> scripts. I found this when you select "env" under Global Variables in the
> snippet generator:
>
> The following variables are currently unavailable inside a workflow script:
>
>- EXECUTOR_NUMBER
>- NODE_LABELS
>- WORKSPACE
>- SCM-specific variables such as SVN_REVISION
>
>
>
> On 1/27/2016 4:14 AM, David Karlsen wrote:
>
> I have this build definition:
>
> node ('docker') {
>   wrap([$class: 'TimestamperBuildWrapper']) {
> stage 'checkout'
> checkout scm: [$class: 'GitSCM', branches: [[name: '*/develop']],
> userRemoteConfigs: [[url: ' 
> ssh://git@myserver:port/myrepo.git']]]
>
> stage 'unit-test'
> env.JAVA_HOME="${tool 'Oracle-JDK8-64bit'}"
> def mvnHome = tool 'apache-maven-3.x'
> def workSpace = env.WORKSPACE
> def mvnCmd = "${mvnHome}/bin/mvn -B
> -Dmaven.repo.local=${workSpace}/.m2"
> echo "workspace: ${workSpace} mvnCmd: ${mvnCmd}"
> sh "${mvnCmd}/bin/mvn -B clean install"
> 
>
>
>
>
> But workspace is null:
>
> Running: Print Message*08:55:38* *workspace: null* mvnCmd: 
> /var/lib/jenkins/tools/maven/apache-maven-3.x/bin/mvn -B 
> -Dmaven.repo.local=null/.m2
>
>
> Should it not be assigned to the env.WORKSPACE var by default?
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/jenkinsci-users/5d2f08e0-f692-4b6e-a657-dbb5bc66a251%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/56A9114F.8080909%40cd-adapco.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAG%3DrPVd7Utrt3RmOhrqePhHrkkO-iLwjFwBPXsQ48Af4%3DwnoKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: No workspace variable during workflow / pipeline build?

2016-01-27 Thread Eric Pyle

Workaround:

sh 'pwd > pwd.txt'
workspace = readFile('pwd.txt')

On 1/27/2016 1:15 PM, Eric Pyle wrote:
WORKSPACE is documented as not being available in workflow/pipeline 
scripts. I found this when you select "env" under Global Variables in 
the snippet generator:


The following variables are currently unavailable inside a workflow 
script:


  * |EXECUTOR_NUMBER|
  * |NODE_LABELS|
  * |WORKSPACE|
  * SCM-specific variables such as|SVN_REVISION|



On 1/27/2016 4:14 AM, David Karlsen wrote:

I have this build definition:

node ('docker') {
  wrap([$class: 'TimestamperBuildWrapper']) {
stage 'checkout'
checkout scm: [$class: 'GitSCM', branches: [[name: '*/develop']], 
userRemoteConfigs: [[url: 'ssh://git@myserver:port/myrepo.git']]]


stage 'unit-test'
env.JAVA_HOME="${tool 'Oracle-JDK8-64bit'}"
def mvnHome = tool 'apache-maven-3.x'
def workSpace = env.WORKSPACE
def mvnCmd = "${mvnHome}/bin/mvn -B 
-Dmaven.repo.local=${workSpace}/.m2"

echo "workspace: ${workSpace} mvnCmd: ${mvnCmd}"
sh "${mvnCmd}/bin/mvn -B clean install"





But workspace is null:

Running: Print Message
*08:55:38* *workspace: null*  mvnCmd: 
/var/lib/jenkins/tools/maven/apache-maven-3.x/bin/mvn -B 
-Dmaven.repo.local=null/.m2

Should it not be assigned to the env.WORKSPACE var by default?
--
You received this message because you are subscribed to the Google 
Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, 
send an email to jenkinsci-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/5d2f08e0-f692-4b6e-a657-dbb5bc66a251%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.




--
You received this message because you are subscribed to the Google Groups "Jenkins 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/56A9114F.8080909%40cd-adapco.com.
For more options, visit https://groups.google.com/d/optout.


Re: No workspace variable during workflow / pipeline build?

2016-01-27 Thread Eric Pyle
WORKSPACE is documented as not being available in workflow/pipeline 
scripts. I found this when you select "env" under Global Variables in 
the snippet generator:


The following variables are currently unavailable inside a workflow script:

 * |EXECUTOR_NUMBER|
 * |NODE_LABELS|
 * |WORKSPACE|
 * SCM-specific variables such as|SVN_REVISION|



On 1/27/2016 4:14 AM, David Karlsen wrote:

I have this build definition:

node ('docker') {
  wrap([$class: 'TimestamperBuildWrapper']) {
stage 'checkout'
checkout scm: [$class: 'GitSCM', branches: [[name: '*/develop']], 
userRemoteConfigs: [[url: 'ssh://git@myserver:port/myrepo.git']]]


stage 'unit-test'
env.JAVA_HOME="${tool 'Oracle-JDK8-64bit'}"
def mvnHome = tool 'apache-maven-3.x'
def workSpace = env.WORKSPACE
def mvnCmd = "${mvnHome}/bin/mvn -B 
-Dmaven.repo.local=${workSpace}/.m2"

echo "workspace: ${workSpace} mvnCmd: ${mvnCmd}"
sh "${mvnCmd}/bin/mvn -B clean install"





But workspace is null:

Running: Print Message
*08:55:38* *workspace: null*  mvnCmd: 
/var/lib/jenkins/tools/maven/apache-maven-3.x/bin/mvn -B 
-Dmaven.repo.local=null/.m2

Should it not be assigned to the env.WORKSPACE var by default?
--
You received this message because you are subscribed to the Google 
Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to jenkinsci-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/5d2f08e0-f692-4b6e-a657-dbb5bc66a251%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Jenkins 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/56A9093B.5030403%40cd-adapco.com.
For more options, visit https://groups.google.com/d/optout.