Deploy Jenkins | (Just Updated) CI/CD Server, Generated Admin Login and API Token
Jenkins CI/CD server with Pipeline, Git, JCasC, generated admin login
Just deployed
/var/jenkins_home
Deploy and Host Jenkins on Railway
Built for an LLM agent to deploy and use. There is no setup wizard and nothing to fill in: the admin password and an API token are generated at deploy time, Jenkins is configured as code on first boot, the contract below lists every URL and variable name, and one working script creates a Pipeline job and runs it over the REST API.
Jenkins is the open-source automation server for building, testing and deploying software: Pipelines as code, thousands of plugins, distributed builds. This template runs the official Jenkins LTS image (JDK 21) with a small wrapper that preinstalls the common plugins and creates the admin login, and keeps JENKINS_HOME on a Railway volume so jobs, credentials and build history survive redeploys.
About Hosting Jenkins
This template runs one service, built from the official jenkins/jenkins lts-jdk21 image (pinned by digest) in the public wrapper bon5co/jenkins-railway, with the volume at /var/jenkins_home. The setup wizard is disabled and Jenkins is configured by Configuration as Code: one admin user whose password is JENKINS_ADMIN_PASSWORD, anonymous access off, sign-up off, and the Jenkins URL taken from the Railway public domain. An init script installs JENKINS_API_TOKEN as a fixed API token for admin, so scripts can authenticate without a browser. About 80 plugins are preinstalled, including Pipeline, Git, GitHub, Credentials Binding, Timestamper and Matrix Authorization. The entrypoint runs as root only to fix ownership of the root-owned Railway volume, then drops to the jenkins user.
The built-in node runs 2 executors, which is enough for light builds. For heavy builds add an agent: Railway cannot expose the classic inbound agent port 50000 here (a public TCP proxy and the HTTP healthcheck are mutually exclusive on one service), so agents connect over WebSocket through the public HTTPS URL (java -jar agent.jar -url $JENKINS_URL -webSocket ...).
Agent contract
- Public URL:
https://, on thejenkinsservice (setJENKINS_URLto it, no trailing slash) - Private URL:
http://jenkins.railway.internal:8080 - Credentials: user
admin, password inJENKINS_ADMIN_PASSWORD, API token inJENKINS_API_TOKEN(both on thejenkinsservice) - Auth: HTTP Basic with
adminandJENKINS_API_TOKEN(or the password) on every API call; anonymous requests get 403; API-token calls need no CSRF crumb - Health:
GET /loginreturns 200 with no credentials
# run with JENKINS_URL, JENKINS_API_TOKEN (jenkins service); needs curl
A="admin:$JENKINS_API_TOKEN"
curl -s -o /dev/null -w 'health %{http_code}\n' "$JENKINS_URL/login"
curl -s -o /dev/null -w 'anonymous %{http_code}\n' "$JENKINS_URL/api/json"
cat > /tmp/job.xml <<'XML'
true
XML
curl -fsS -u "$A" -H 'Content-Type: application/xml' --data-binary @/tmp/job.xml "$JENKINS_URL/createItem?name=hello" -o /dev/null -w 'create %{http_code}\n'
curl -fsS -u "$A" -X POST "$JENKINS_URL/job/hello/build" -o /dev/null -w 'queue %{http_code}\n'
for i in $(seq 1 60); do R=$(curl -s -u "$A" "$JENKINS_URL/job/hello/lastBuild/api/json" | grep -o '"result":"[A-Z]*"'); [ -n "$R" ] && break; sleep 2; done; echo "build $R"
A fresh deploy prints health 200, anonymous 403, create 200, queue 201 and build "result":"SUCCESS". Add real jobs the same way (/createItem), or open the public URL and sign in as admin to use the web interface.
Why Deploy Jenkins 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 Jenkins 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.
- Agent-ready - generated admin password and API token, a contract block and one working script; no setup wizard.
- Configured as code - admin user, security and Jenkins URL are set by the first start.
- Stable login - the admin password and API token are the same after every redeploy.
- State survives redeploys - jobs, credentials and build history live on the volume.
Common Use Cases
- CI for a repository - build and test on every push with a Jenkinsfile Pipeline.
- Agent-driven builds - let an AI agent create jobs and read build results through the REST API.
- Scheduled automation - nightly jobs, release pipelines and maintenance scripts.
Dependencies for Jenkins Hosting
- A volume at
/var/jenkins_home(included in this template).
Deployment Dependencies
- jenkinsci/jenkins - upstream project
- bon5co/jenkins-railway - the wrapper image this template deploys, built from jenkins/jenkins lts-jdk21 (Jenkins 2.580.2)
Template Content
