Matrix in Pipelines

18 views
Skip to first unread message

Roland Asmann

unread,
Oct 18, 2020, 12:23:48 PM10/18/20
to Jenkins Users
Hey everybody,

I have this job, written as a declarative pipeline, the now needs to be run on 2 nodes instead of just 1. Before, I would use the Matrix-Job for that, but I am not quite sure how to do this in my pipeline...
I searched around a bit and found some example on how to do it with a scripted pipeline, but I would prefer to stick to the declarative format -- if possible. The reason for that is that my team is just learning about pipelines and have just about mastered declarative. I don't want to throw them in the deep end for scripted yet.

Is this possible in declarative? If so, tips would be helpful.
If not, at least 1 reply telling me this would also be helpful! ;-)

Thanks,
Roland

Jan Monterrubio

unread,
Oct 18, 2020, 11:53:57 PM10/18/20
to jenkins...@googlegroups.com
Could you do a job that takes a Node parameter and then a job with 2 stages, one for each node that just calls the first job?

--
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/8ebffe59-9ac7-489a-9bf1-388d77ea7289n%40googlegroups.com.

christop...@googlemail.com

unread,
Oct 19, 2020, 3:45:14 AM10/19/20
to Jenkins Users
Hi,

I don't exactly understand your problem. Please have a look here:

you very easily can integrate matrix in a declarative pipeline. Insert your nodes as an axis of the matrix and add an 'agent' in the stage doing your job.

But maybe I missed a point somewhere...

Roland Asmann

unread,
Oct 19, 2020, 4:16:51 AM10/19/20
to jenkins...@googlegroups.com
Hi,

Thanks for that. I see I forgot to mention something in my original
post: The nodes I want to run my job on should come from a label. So I
would need to get the 'values' in the matrix-part by figuring out which
nodes have this label set...

Can I add a simple 1-, maybe 2-line script block in my pipeline to
retrieve those values and use them?
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Jenkins Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jenkinsci-users/DLoPOi8U5NI/unsubscribe <https://groups.google.com/d/topic/jenkinsci-users/DLoPOi8U5NI/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to
> jenkinsci-use...@googlegroups.com
> <mailto:jenkinsci-use...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/5d806b70-3cab-463e-a27f-097daaa3679en%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/5d806b70-3cab-463e-a27f-097daaa3679en%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

christop...@googlemail.com

unread,
Oct 19, 2020, 6:27:21 AM10/19/20
to Jenkins Users
You mean something like a dynamic axis created by a piece of script? I had a similar issue in the past and did not find a way.
There might be something with script blocks in a pipeline and dynamic stage-creation with a for-loop.
When I remember right I found some examples with google when I investigated this.

Roland Asmann

unread,
Oct 20, 2020, 5:31:45 PM10/20/20
to jenkins...@googlegroups.com
Thanks for the replies. I went with hard-coding the 2 nodes, in the
hopes that at some point the matrix will allow use of variables for the
value.
> <https://groups.google.com/d/msgid/jenkinsci-users/5d806b70-3cab-463e-a27f-097daaa3679en%40googlegroups.com?utm_medium=email&utm_source=footer
> https://www.avast.com/antivirus <https://www.avast.com/antivirus>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Jenkins Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jenkinsci-users/DLoPOi8U5NI/unsubscribe <https://groups.google.com/d/topic/jenkinsci-users/DLoPOi8U5NI/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to
> jenkinsci-use...@googlegroups.com
> <mailto:jenkinsci-use...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/12a60d25-485a-4cf3-a237-a45a470ba959n%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/12a60d25-485a-4cf3-a237-a45a470ba959n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages