combine multiple pipeline steps

56 views
Skip to first unread message

Ioannis Canellos

unread,
Aug 2, 2016, 8:51:46 AM8/2/16
to Jenkins Developers
Hi all,

I have a couple of pipeline steps that I want to have the combined as one.
For example I have the 'configure' step which returns a label and I want to combine it with the node step as follows:

label = configure()
node(label) {
...
}

So, what I want is to create an alternative of node, that encapsulates the above.
Any hints on where I should look?

Adrien Lecharpentier

unread,
Aug 2, 2016, 8:56:54 AM8/2/16
to Jenkins Developers
Hi,

you could create a function take a clojure in parameter and use it. For example:

def myenvironment(def body) {
  def label = configure()
  node(label) {
    body.call()
  }
}

and use it like

myenvironment {
  sh "make"
}

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/4d77a7a6-1f1a-43b9-82f1-a73e5147f56b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Baptiste Mathus

unread,
Aug 2, 2016, 9:01:26 AM8/2/16
to Jenkins Developers

Ioannis Canellos

unread,
Aug 2, 2016, 11:53:54 AM8/2/16
to Jenkins Developers, m...@batmat.net
And how do I wrap a snippet like this inside a jenkins plugin?

Jesse Glick

unread,
Aug 4, 2016, 10:50:20 AM8/4/16
to Jenkins Dev
On Tue, Aug 2, 2016 at 11:53 AM, Ioannis Canellos <ioc...@gmail.com> wrote:
> And how do I wrap a snippet like this inside a jenkins plugin?

See `docker-workflow` for an example of `GroovyShellDecorator`.
Probably a higher-level API will be introduced in the future.
Reply all
Reply to author
Forward
0 new messages