How to change the current workspace in a pipeline script?

51 views
Skip to first unread message

Sandra Parsick

unread,
Apr 8, 2018, 5:59:48 AM4/8/18
to Jenkins Users
Hello,

I'd like to change the current workspace in a pipeleine script. My naive approach is the following script

pipeline {
    agent any
    environment
{
        WORKSPACE
= '/home/sparsick'
   
}
    stages
{
        stage
('Build') {
            steps
{
                sh
'echo $WORKSPACE'
                sh
'pwd'
           
}
       
}
     
   
}
}

The output of this script:

Running on Jenkins in /home/sparsick/dev/jenkins-2.0/workspace/Workspace Change In Pipeline
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] sh
[Workspace Change In Pipeline] Running shell script
+ echo /home/sparsick
/home/sparsick
[Pipeline] sh
[Workspace Change In Pipeline] Running shell script
+ pwd
/home/sparsick/dev/jenkins-2.0/workspace/Workspace Change In Pipeline
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

I expected that the output of the pwd command is the same as the output of the echo command. But It isn't. So my question how I can change the current workspace in a pipeline script?

Thank you and best regards,

Sandra

Mark Waite

unread,
Apr 8, 2018, 10:09:48 AM4/8/18
to jenkins...@googlegroups.com
On Sun, Apr 8, 2018 at 4:00 AM 'Sandra Parsick' via Jenkins Users <jenkins...@googlegroups.com> wrote:
Hello,

I'd like to change the current workspace in a pipeleine script.

--
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/63b8f006-6db3-4c90-b547-afac04d83685%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sandra Parsick

unread,
Jul 11, 2018, 5:50:14 AM7/11/18
to Jenkins Users
Thank you for help
Reply all
Reply to author
Forward
0 new messages