[workflow] - First failing Newbie (dir) steps

25 views
Skip to first unread message

Markus "Shorty" Uckelmann

unread,
May 27, 2015, 11:23:22 AM5/27/15
to jenkins...@googlegroups.com
Hi all,

I just started to play a bit with the workflow-plugin and got stuck with
dir step. My "awesome" code:

stage 'box'
node ('admins') {
def dir = '7packer-boxes'
sh "mkdir ${dir} || :"
echo "Changing to dir ${dir}"
sh "pwd"
dir("${dir}") {
sh "pwd"
}
}


The build starts, works to the point where the dir step is and then
doesn't do anything. Also it just keeps running and I can't remove the
build[1].

Jenkins: 1.596.3
Workflow: 1.6

Any help would be much appreciated.


[1] With /doDelete I can remove it from the slave but it still exists on
the master. A restart of Jenkins might help.


Cheers, Shorty

Craig Rodrigues

unread,
Jun 1, 2015, 6:18:52 PM6/1/15
to jenkins...@googlegroups.com
Hi,

If you are going to use the workflow plugin, I highly recommend you
watch this Youtube video by Cyrille Le Clerc from Cloudbees:

https://www.youtube.com/watch?v=Welwf1wTU-w

That video is so good, I think it should be, put in the README.md file for the Workflow plugin.

I'm not sure, but I think most of your code is unnecessary, unless you have it there for debugging.

I think this should work, but you might want to change the name of the dir
variable just to not clash with the dir() function:

node ('admins') {
     def mydir = '7packers-boxes'
      dir("${mydir}") {
          sh "pwd"
      }
}

The dir() function should create the directory, and in the block, it internally
does a chdir() to that directory and then executes the code in that block.

Regarding cleaning things up, I filed this bug:
https://issues.jenkins-ci.org/browse/JENKINS-28382 "workflow plugin: no option to Wipe Out Current Workspace".
That bug got marked as a duplicate.  There are definitely issues with respect to cleaning up
workspaces used by the workflow plugin.

--
Craig




--
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/5565E15F.6070808%40koeln.de.
For more options, visit https://groups.google.com/d/optout.

Markus "Shorty" Uckelmann

unread,
Jun 2, 2015, 2:58:43 AM6/2/15
to jenkins...@googlegroups.com
Am 02.06.2015 um 00:18 schrieb Craig Rodrigues:
| Hi,

Hola Craig,

| If you are going to use the workflow plugin, I highly recommend
| you watch this Youtube video by Cyrille Le Clerc from Cloudbees:

Aye, will do.

| That video is so good, I think it should be, put in the README.md
| file for the Workflow plugin.

Anything that helps.

| I'm not sure, but I think most of your code is unnecessary, unless
| you have it there for debugging.

Jep, it's for debugging.

| I think this should work, but you might want to change the name of
| the dir variable just to not clash with the dir() function:
|
| node ('admins') { def mydir = '7packers-boxes'

That did the trick! Stupid me...

| The dir() function should create the directory, and in the block,
| it internally does a chdir() to that directory and then executes
| the code in that block.

Ahh, I didn't even know that "dir" creates directories. I wasn't able
to find the documentation for this function. So I was kind of
stumbling in the dark. Are there docs for functions like dir?

| Regarding cleaning things up, I filed this bug:
| https://issues.jenkins-ci.org/browse/JENKINS-28382 "workflow
| plugin: no option to Wipe Out Current Workspace". That bug got
| marked as a duplicate. There are definitely issues with respect to
| cleaning up workspaces used by the workflow plugin.

Ok, I see if I can jump on this train too ;)

Thanks a lot mate! I was near desperation since noone answered... ;)

Cheers, Shorty

Reply all
Reply to author
Forward
0 new messages