How can I make a label change be effective?

255 views
Skip to first unread message

Christian Goetze

unread,
May 9, 2014, 3:40:42 PM5/9/14
to jenkins...@googlegroups.com
I just filed https://issues.jenkins-ci.org/browse/JENKINS-22954

It appears that if I change the node label string via groovy, that change is not immediately effective, even if I save the model.

If I launch a subtask from the task that make the label change, that subtask will run on a node where it should not run.

Is there some call I am missing to make a label change to the nodes be effective?

Daniel Beck

unread,
May 9, 2014, 3:48:41 PM5/9/14
to jenkins...@googlegroups.com
I commented on the issue with an explanation and how to solve your problem.
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

Christian Goetze

unread,
May 11, 2014, 4:06:28 AM5/11/14
to jenkins...@googlegroups.com
Sadly, the trimLabels() method is private. Is there a public method to achieve this, or do I really need to call setNodes(getNodes())

Daniel Beck

unread,
May 11, 2014, 9:20:32 AM5/11/14
to jenkins...@googlegroups.com
Didn't notice the visibility of Jenkins#trimLabels() -- But when it's about use in script, Groovy's rules are weird anyway.

My other suggestion to use Label.reset() works however: Jenkins#trimLabels() is mostly the same as `Jenkins.instance.labels.each { it.reset() }`, which works for me from Script Console. More targeted resetting can be done by checking whether the label you're processing is one of the labels affected by your rules.

Christian Goetze

unread,
May 11, 2014, 7:23:36 PM5/11/14
to jenkins...@googlegroups.com
Thanks, that seems to work...
Reply all
Reply to author
Forward
0 new messages