Two solutions have came to my mind:
First method is based on an idea of making REST call from node("master") {
sh "curl ..." } to confirm if Jenkins instance contains node.
Second method is only applicable if your Pipeline script is "trusted" and
it's not run inside "a sandbox". Then you could make a Java/Groovy call
directly targeting Jenkins instance using API.
Cheers,
W dniu czwartek, 8 czerwca 2017 17:49:11 UTC+2 użytkownik Ali Ok napisał:
>
> I have a Jenkins pipeline like:
>
> node("slave1"){
> echo "Building very very complicated things"
> }
>
> If the node "slave1" does not exist in my Jenkins setup, the build is
> stuck forever.
>
> I know I could use timeout keyword and wrap the node command. However,
> this is not good since timeout can happen because of inexistent node or
> long-taking build. That's not really a solution.
>
> Any calls that I can do to check if a node exists or not?
>
> I understand I can use timeout and wrap something like this :
> node("slave1"){echo
> "Hello"} . That way I can test if node exists. However, this actually
> makes a connection to the node (in my case, spawns a container in
> OpenShift/Kubernetes and wastes it immediately)
>
> I use Jenkins 2.32.2 and pipeline plugin version 2.1.
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/7c82b96d-c7aa-4fc7-bc5d-8b27b7b9d280%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.