bpedroso
bpedroso

Reputation: 4897

Jenkinsfile in a node with hostname

I would like to execute my job in a remote node passing the domain name as node arg.

Someone knows how to build this jenkinsfile?

I can't execute on the below way

node('jenkins.mydomain.com') {
    build 'remote_exec'
}

Upvotes: 0

Views: 861

Answers (1)

StephenKing
StephenKing

Reputation: 37580

There are actually two major issues within your two lines of code :-)

node('jenkins.mydomain.com') {

This will build on a build agent with the label jenkins.mydomain.com. If you have only one build agent with this label given, this should work. But it's not the hostname! (Note: I'm not entirely sure if dots are allowed, but you could call it also whateverserver).

So this would allocate an executor slot (to run the code within the closure) on a build agent matching the given label...

build 'remote_exec'

and then trigger yet another build for the job called remote_exec. This job (assuming it exists and you don't have this as a third issue^^) will then be built on an agent matching its own labels, ignoring the one given in the node(label) step.

If you want that the remote_exec job runs on a specific build agent only, then add the node step there!

Upvotes: 2

Related Questions