[workflow-plugin] Use external script for running the flow

70 views
Skip to first unread message

Timur Batyrshin

unread,
Jan 19, 2015, 5:05:19 AM1/19/15
to jenkins...@googlegroups.com
Hi,

I'd like to store the script for running the flow in Git but it looks like I can't do the SCM checkout before running the flow.
I could write some additional lines in the flow script (one for checkout and one "load" command) but the checkout commands
are too large in the current state (like:
checkout changelog: true, poll: true, scm: [$class: 'GitSCM', branches: [[name: 'remotes/origin/master']], userRemoteConfigs: [[credentialsId: 'XXXXXXX-XXXXXX-XXXXX-XXXXXXX', url: 'https://github.com/XXXXX/XXXXXX.git']]]
).

Is there a way to do the initial checkout using plain Jenkins checkout feature or should I use this approach? Probably some other ways of doing that?


Thanks,
Timur

Thomas Goeppel

unread,
Jan 31, 2015, 4:59:20 PM1/31/15
to jenkins...@googlegroups.com
Hi Timur,

good news, loading the CPS script from SCM (i.e. Git or SVN) is one of the new features in workflow plugin 1.2. Just add your script to your SCM, select "Groovy CPS DSL from SCM" instead of ""Groovy CPS DSL", enter your repository, and the name of your Groovy CPS script.

I did a quick test with Subversion: it works, but I had to experiment a while with the settings to make my script work. It looks like Jenkins tries to be "smart" about the location of trunk/ in the repository path, which is odd, since the repository structure should be none of its business ;-)

I also couldn't figure out what "Local module directory", and "Add module" are about. After setting the "Locale module directory", I had to add a "dir { }" instruction. Without that the script started in the wrong directory. I guess, that these are Subversion related issues.

/Thomas

Timur Batyrshin

unread,
Jan 31, 2015, 7:45:16 PM1/31/15
to jenkins...@googlegroups.com
Hi Thomas,

Yes, I've noticed the new version soon and I'm using it for about a week. Sorry that I've not updated the maillist with my finding.
I'm using git for the groovy script and it works exactly the same as if I used standalone git checkout.
I've just could not figure out how to correctly specify additional actions like "Cleanup workdir after checkout".
If you know how to do that please let me know.

Thanks,
Timur 

воскресенье, 1 февраля 2015 г., 0:59:20 UTC+3 пользователь Thomas Goeppel написал:

Thomas Goeppel

unread,
Feb 1, 2015, 9:57:14 AM2/1/15
to jenkins...@googlegroups.com
Hi Timur,

did I get this right, besides the "Groovy CPS DSL from SCM" you don't use a general a "General SCM" step?

In my understanding, loading the flow definition from an SCM is just a special case of using multiple SCMs (at least that's what I would expect it to be). Did you try using an additional "General SCM" step with the "Cleanup workdir" option active?

/Thomas

Timur Batyrshin

unread,
Feb 3, 2015, 2:52:45 AM2/3/15
to jenkins...@googlegroups.com
Hi Thomas,

I use only "Groovy CPS DSL from SCM" for loading the workflow code and it works fine.
It allocates a workspace named "workspace@script", does the checkout and runs workflow from it and all is fine.

Sorry for the confusion, I think I've meant different thing from another thread here when I was talking about additional actions.
That is when I use the GeneralSCM step inside build flow I don't know how to add additional action there.
Sorry again for breaking the topic. I really should have had some sleep till morning before posting an email.


Thanks,
Timur

воскресенье, 1 февраля 2015 г., 17:57:14 UTC+3 пользователь Thomas Goeppel написал:
Reply all
Reply to author
Forward
0 new messages