Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the working directory in Jenkins after executing a shell command box?

I'm looking at a Jenkins job and trying to understand it.

I have an Execute shell command box in my Build section:

> mkdir mydir 
> cd mydir
> 
> svn export --force https://example.com/repo/mydir .

When Jenkins is done executing that command, and moves on to the next build step, what is its working directory? workspece-root/ or workspace-root/mydir ?

As the next step, I have Invoke top-level Maven targets (still in the Build section).

What I really want to know is: why does that execute successfully?
Is it because Jenkins automatically moves back to the workspace-root/ folder after executing a shell command box, or is it because the next job is a "top-level" job, and Jenkins therefore changes back to the workspace-root/?

like image 384
Christian Avatar asked Jun 25 '14 15:06

Christian


People also ask

Where do I put Jenkins executable commands?

Jenkins web console > Manage Jenkins > Configure System > Under shell, set the "Shell executable" = C:\cygwin64\bin\sh.exe > Click apply & also click save.


1 Answers

Each build step is a separate process that Jenkins spawns off. They don't share anything, neither current directory, nor environment variables set/changed within the build step. Each new build step starts by spawning a new process off the parent process (the one running Jenkins)

It's not that Jenkins "move back" to $WORKSPACE. It's that Jenkins discards the previous session.

like image 61
Slav Avatar answered Sep 23 '22 11:09

Slav