# Failback to master agent if other agents arent avaliable

**URL:** <https://community.jenkins.io/t/failback-to-master-agent-if-other-agents-arent-avaliable/3426>\
**Category:** Using Jenkins\
**Tags:** question\
**Created:** [August 18, 2022, 1:05pm UTC](https://community.jenkins.io/t/failback-to-master-agent-if-other-agents-arent-avaliable/3426 "2022-08-18T13:05:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rita.morgan](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@rita.morgan](https://community.jenkins.io/u/rita.morgan)\
**Post date:** [August 18, 2022, 1:05pm UTC](https://community.jenkins.io/t/failback-to-master-agent-if-other-agents-arent-avaliable/3426/1 "2022-08-18T13:05:10Z")

</div>

[reference](https://groups.google.com/g/jenkinsci-users/c/WYRX8m1H-cA)  
Using a Jenkinsfile, I have 2 agents (master, nodeA).

I prefer my job to run on nodeA. If its not available (its a ec2 instance), i want it to run on master.

Is there a way to declare this in a pipeline? I know there is a feature to prefer an agent or explicity set it as a label but I really want the logic to be in a pipeline.

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [August 21, 2022, 2:53pm UTC](https://community.jenkins.io/t/failback-to-master-agent-if-other-agents-arent-avaliable/3426/2 "2022-08-21T14:53:25Z")

</div>

Hi there,

As a reminder, the term “master” to refer to a controller has been deprecated since 2020. Please refer to [On Jenkins Terminology Updates](https://www.jenkins.io/blog/2020/06/18/terminology-update/) for more details. We request you update your post.

Thanks,  
Mark Waite

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [August 21, 2022, 3:01pm UTC](https://community.jenkins.io/t/failback-to-master-agent-if-other-agents-arent-avaliable/3426/3 "2022-08-21T15:01:46Z")

</div>

Pipelines can select their agent based on a label. Label it to use the agent and follow the recommended practice of not enabling an executor on the controller.

> **[Controller Isolation](https://www.jenkins.io/doc/book/security/controller-isolation/)**
>
> Jenkins – an open source automation server which enables developers around the world to reliably build, test, and deploy their software

If you want an agent on the same host that runs the controller, define an agent that uses a separate account on the same host that runs the controller. Then you can label the job to use either agent. I’m not aware of a way to force Jenkins to prefer one agent label over another for a specific Pipeline job.

The [scoring load balancer plugin](https://plugins.jenkins.io/scoring-load-balancer/) might be able to help, though it is old enough that I am not confident that it will work with a modern Jenkins controller.

---

<div class="post-metadata">

**Author:** ![steved](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/steved/32/2026_2.png) [@steved](https://community.jenkins.io/u/steved)\
**Post date:** [August 22, 2022, 10:06pm UTC](https://community.jenkins.io/t/failback-to-master-agent-if-other-agents-arent-avaliable/3426/4 "2022-08-22T22:06:18Z")

</div>

This link doesn’t actually tell OP what to use in place of the discouraged term. It says the team is working on a plan, but there is no alternative clearly defined. I believe the Jenkins UI uses ‘Built-In Node’ to idintify the agent on the main Jenkins server.

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [August 22, 2022, 10:17pm UTC](https://community.jenkins.io/t/failback-to-master-agent-if-other-agents-arent-avaliable/3426/5 "2022-08-22T22:17:25Z")

</div>

Thanks for noting that. How about, “Please refer to the [Jenkins glossary](https://www.jenkins.io/doc/book/glossary/#master)” where it says:

> **controller**
> 
> A deprecated term, synonymous with [Controller](https://www.jenkins.io/doc/book/glossary/#controller).
