Custom pipeline jobs

44 views
Skip to first unread message

Chris Overend

unread,
Feb 20, 2019, 11:08:05 AM2/20/19
to Jenkins Users
Is it possible to pass groovy scripts to a pipeline job
I want to be able to configure custom groovy scripts based on options selected by my users.
I could have a massive script with many "if" clauses.
It would be nicer to create a groovy script based on selected options.
this api would then be testable internally.

I have tried a few tests run but it does not appear that the groovy being passed is being executed.

groovy_script = "stage('testing')  {\n    build job: 'echo'\n}\n"

parameters: [string(name: 'groovy_script', value: groovy_script)

jenkins pipeline job
"""
#!groovy
import hudson.model.*

groovy_script
"""
I was hoping this would evaluate to 

"""
#!groovy
import hudson.model.*

stage('testing')  {
    build job: 'echo'
}
"""

any ideas?

Chris Overend

unread,
Mar 1, 2019, 11:35:58 AM3/1/19
to Jenkins Users
Anyone have any ideas how I can create dynamic pipeline scripts

Jenn Briden

unread,
Mar 1, 2019, 12:42:09 PM3/1/19
to jenkins...@googlegroups.com
What are you trying to do that wouldn't work in a standard pipeline? We are working on pipeline improvements, so it's useful to understand why people resort to scripting.

On Fri, Mar 1, 2019, 08:36 Chris Overend <chris....@vectorcast.com> wrote:
Anyone have any ideas how I can create dynamic pipeline scripts

--
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/cb9b11ba-7295-4852-86f3-2a54733b0a70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

RAJENDRA PRASAD

unread,
Mar 1, 2019, 9:08:09 PM3/1/19
to jenkins...@googlegroups.com
Hope this link can help you: https://jenkins.io/doc/pipeline/steps/workflow-cps/

Thanks,
Rajendra

On Fri, 1 Mar, 2019, 22:06 Chris Overend, <chris....@vectorcast.com> wrote:
Anyone have any ideas how I can create dynamic pipeline scripts

--

Chris Overend

unread,
Mar 4, 2019, 4:04:39 PM3/4/19
to Jenkins Users
Jenn,
We do not test with a CI strategy. We have a limited number things that we do with some parallelization.
1. clone or merge
2. in parallel
     a. build product for (window (32, 64), linux (32, 64))
     b. run many different types of tests
     c. generate report on tests
3. generate consolidated reports

Currently I have a different pipeline for many of the preferred configurations we want our developers to use.
I want to be able to allow my developers to select from all of the available options.

I could put all of these options in 1 pipeline and have if conditions at every decision point.
This maybe challenging to get perfect with the diff parallels it would have.

I thought it would be powerful to pass a generated script based on available choices to a generic pipeline job.
I could then handle all of the complex logic outside of the groovy script.
This logic could be unit tested and in revision control.


Reply all
Reply to author
Forward
0 new messages