
Deploy Jenkins Agent
A Jenkins automation agent.
Jenkins Agent
Just deployed
/home/jenkins/agent
Deploy and Host a Jenkins Inbound Agent on Railway
A Jenkins inbound agent is a worker process that connects out to a Jenkins controller and executes build jobs on its behalf. Unlike an SSH-launched agent, the connection is initiated by the agent itself, making it a natural fit for containerized environments like Railway where you don't want to expose inbound access to the worker.
About Hosting a Jenkins Agent
An inbound agent needs three things to run: the URL of your Jenkins controller, the agent name registered on that controller, and a secret generated by the controller for that agent. Once connected, it stays idle until the controller assigns it a build, executes the job, and reports results back. Because the agent dials out rather than accepting inbound connections, Railway can host it without any special network configuration on the agent side, you just need the controller reachable from it.
Common Use Cases
- Running build jobs isolated from the Jenkins controller for better resource separation and security
- Scaling build capacity horizontally by adding more agent instances
- Running builds with a specific JDK, OS, or toolchain different from the controller's environment
- Isolating untrusted or resource-heavy jobs away from the controller process
Dependencies for Jenkins Agent Hosting
- A running Jenkins controller (see the Jenkins template)
- An agent name and secret generated from the controller (Manage Jenkins → Nodes → New Node)
Implementation Details
This template deploys the official jenkins/inbound-agent image, configured with three environment variables: JENKINS_AGENT_NAME, JENKINS_SECRET, and JENKINS_URL. If you need a specific JDK for your builds, pin the image tag accordingly (e.g. jenkins/inbound-agent:jdk21) rather than relying on the default. The JDK the agent runs on is independent of the JDK your build jobs actually compile or run against, so pick agent images with your job's toolchain in mind, or install additional JDKs as build tools.
Agent Setup
Jenkins Node Setup
Follow these steps to create a node in your Jenkins instance.
Setup the agent on Jenkins
- Go to your Jenkins dashboard.
- Go to the Manage Jenkins option in the main menu.
- Go to Nodes under System Configuration.
- Go to New Node in the side menu.
- Fill in the Node (agent) name and select the type (e.g. Name:
agent1, Type:Permanent Agent). - Fill in the remaining fields, such as remote root directory, labels, and number of executors:
Remote root directoryshould be set to/home/jenkins/agentLaunch methodshould be set toLaunch agent by connecting it to the controller
- Press Save. The
agent1node will be registered but offline for now. - Click on the new agent.
- You should now see the secret used to configure the template below.
Template configuration
- Set the
JENKINS_AGENT_NAMEenvironment variable to the agent name you selected above. - Set the
JENKINS_SECRETenvironment variable to the secret generated above. - Set the
JENKINS_URLenvironment variable to the URL of your Jenkins instance. If using my Jenkins Template, this should be set tohttp://${{Jenkins.JENKINS_PRIVATE_URL}}:${{Jenkins.JENKINS_PRIVATE_PORT}}. - Deploy it, and it should auto-connect to your Jenkins instance.
Why Deploy a Jenkins Agent on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying a Jenkins agent on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
Jenkins Agent
jenkins/inbound-agent:jdk21JENKINS_URL
Url for the Jenkins server. Should be in the format: http://${{Jenkins.JENKINS_PRIVATE_URL}}:${{Jenkins.JENKINS_PRIVATE_PORT}}
JENKINS_SECRET
The secret as shown on the controller after creating the agent.
JENKINS_AGENT_NAME
The name of the agent, it should match the name you specified when creating the agent on the controller.