To integrate Replit with Jenkins, push code from your Replit project to a GitHub repository, then configure a Jenkins pipeline that triggers on each Git push using a webhook. Jenkins pulls the code, runs your test and build steps, and deploys or notifies on completion. No Jenkins agent runs inside Replit — Replit is the code source, Jenkins is the CI/CD runner.
Why Connect Replit to Jenkins?
Replit is an excellent environment for writing and iterating code in the browser — but for teams with established CI/CD workflows, production deployments should go through a quality gate: automated tests, security scans, build validation, and controlled deployment. Jenkins provides exactly this infrastructure, and connecting it to your Replit workflow means every push from Replit automatically triggers the same pipeline your team already trusts.
The integration is straightforward: Replit's built-in Git panel pushes commits to GitHub (or GitLab), and Jenkins has a webhook-based trigger that fires on every push to the specified branch. From there, Jenkins reads the Jenkinsfile in your repository and executes whatever steps you have defined — running Node.js tests, building Docker images, deploying to Kubernetes, or sending Slack notifications on failure.
This workflow is particularly valuable for teams where some developers use Replit (for quick prototyping or browser-based development) while the team's production CI/CD runs on self-hosted Jenkins. It ensures that Replit-originated commits receive the same validation and deployment treatment as commits from any other development environment.
Integration method
The Replit-Jenkins integration connects your Replit development workflow to a Jenkins CI/CD pipeline through Git. You write and iterate code in Replit, push commits to a shared GitHub or GitLab repository, and Jenkins picks up those commits via a webhook trigger. Jenkins then runs your defined pipeline — running tests, building artifacts, and deploying — without requiring any Jenkins installation inside Replit itself.
Prerequisites
- A running Jenkins server accessible from the internet (self-hosted or cloud-hosted Jenkins instance)
- Jenkins with GitHub plugin and Pipeline plugin installed
- A GitHub repository connected to both Replit Git and Jenkins
- A Jenkinsfile in the root of your Replit project's repository
Step-by-step guide
Connect Replit Git to a GitHub Repository
Connect Replit Git to a GitHub Repository
Replit has built-in Git version control accessible via the Git icon in the left sidebar (or Tools → Git). Before connecting to Jenkins, your Replit project needs to be linked to a GitHub repository. If starting fresh: Create a new repository on GitHub (github.com/new). In Replit, go to Tools → Git → connect to the GitHub repo by copying its HTTPS or SSH URL into the remote origin field. If you already have a Replit project with code: Use the Git panel in Replit to initialize the repo if it has not been initialized, then set the remote to your GitHub repository URL. To push code from Replit to GitHub, you will need a GitHub Personal Access Token (PAT) with repo permissions. Generate one at GitHub → Settings → Developer Settings → Personal Access Tokens. When Git asks for credentials in Replit, use your GitHub username and the PAT as the password. Alternatively, if you are using the Replit GitHub integration (connecting through Replit's Settings → Connectors), your Replit project is already synced to a GitHub repo — use that repo URL for your Jenkins configuration.
Pro tip: Store your GitHub PAT in Replit Secrets as GITHUB_TOKEN if you need to script Git operations. For manual Git operations through the Replit UI, the built-in Git panel handles authentication through OAuth.
Expected result: Your Replit project is connected to a GitHub repository. Pushing from the Replit Git panel creates commits visible in GitHub.
Create a Jenkinsfile in Your Repository
Create a Jenkinsfile in Your Repository
Jenkins Pipeline as Code uses a Jenkinsfile stored in the root of your repository. This file defines all the stages and steps Jenkins will execute when it processes a build triggered by a push from Replit. Create a file named Jenkinsfile (no extension) in the root of your Replit project. Jenkins uses either Declarative Pipeline syntax (recommended for most cases) or Scripted Pipeline syntax. The Declarative Jenkinsfile below is a complete Node.js example that installs dependencies, runs tests, and builds the project. Adapt the stages to match your actual application stack and test commands. Key points for Replit projects: - Replit uses Node 18 by default. Specify the same version in your Jenkinsfile's tools block if your Jenkins has multiple Node.js versions configured. - Your package.json test script should produce JUnit-compatible XML output for Jenkins to parse (using jest --ci --reporters=default --reporters=jest-junit or mocha with mocha-junit-reporter). - Environment variables needed by your app at test time should be configured in Jenkins' credential store, not hardcoded.
1// Jenkinsfile — Declarative Pipeline for Replit Node.js project2pipeline {3 agent any45 environment {6 NODE_ENV = 'test'7 }89 tools {10 nodejs 'NodeJS-18' // Matches the Node.js tool name in Jenkins Global Tool Configuration11 }1213 stages {14 stage('Checkout') {15 steps {16 checkout scm17 echo "Building branch: ${env.BRANCH_NAME}, commit: ${env.GIT_COMMIT[0..7]}"18 }19 }2021 stage('Install') {22 steps {23 sh 'node --version'24 sh 'npm --version'25 sh 'npm ci' // Use npm ci for reproducible installs26 }27 }2829 stage('Lint') {30 steps {31 sh 'npm run lint || true' // Don't fail build on lint warnings32 }33 }3435 stage('Test') {36 steps {37 sh 'npm test'38 }39 post {40 always {41 // Publish JUnit test results if your test runner produces XML42 junit allowEmptyResults: true, testResults: 'test-results/**/*.xml'43 }44 }45 }4647 stage('Build') {48 when {49 anyOf {50 branch 'main'51 branch 'master'52 }53 }54 steps {55 sh 'npm run build'56 archiveArtifacts artifacts: 'dist/**', fingerprint: true57 }58 }59 }6061 post {62 success {63 echo 'Pipeline succeeded!'64 }65 failure {66 echo 'Pipeline failed. Check the logs above.'67 }68 always {69 cleanWs() // Clean workspace after build70 }71 }72}Pro tip: Use 'npm ci' instead of 'npm install' in Jenkins pipelines. It installs exactly what is in package-lock.json without modifying it, making builds reproducible and faster.
Expected result: A Jenkinsfile exists in the root of your repository and is committed to GitHub. Jenkins will use this file to define the pipeline when triggered.
Create a Jenkins Pipeline Job
Create a Jenkins Pipeline Job
In your Jenkins web interface, click 'New Item'. Enter a name for your pipeline (e.g., 'replit-app-pipeline'), select 'Pipeline', and click OK. In the pipeline configuration: 1. Under 'Build Triggers', check 'GitHub hook trigger for GITScm polling'. This enables Jenkins to receive webhook events from GitHub. 2. Under 'Pipeline', choose 'Pipeline script from SCM'. 3. Set SCM to 'Git'. 4. Enter your GitHub repository URL (the same repo your Replit project pushes to). 5. Under 'Credentials', add your GitHub credentials (username + PAT) if the repo is private. 6. Set 'Branches to build' to your target branch (e.g., '*/main'). 7. Set 'Script Path' to 'Jenkinsfile'. Click Save. Jenkins will now read your pipeline definition from the Jenkinsfile in your repository. To test the connection: click 'Build Now' manually. Jenkins should clone your repository and run the pipeline stages you defined in the Jenkinsfile. If the build fails, check the console output for the specific error.
Pro tip: Jenkins needs network access to your GitHub repository. If your Jenkins server is behind a firewall, ensure port 443 is open for outbound traffic to github.com. For inbound webhook traffic, GitHub needs to reach your Jenkins server on its public URL.
Expected result: A Jenkins pipeline job is configured and can be triggered manually with 'Build Now'. The pipeline clones your GitHub repository and runs the stages defined in your Jenkinsfile.
Configure GitHub Webhook to Trigger Jenkins on Replit Pushes
Configure GitHub Webhook to Trigger Jenkins on Replit Pushes
A GitHub webhook tells GitHub to notify Jenkins every time code is pushed to your repository. When you push from Replit (via the Git panel), GitHub immediately triggers the Jenkins pipeline — no manual 'Build Now' required. To add the webhook: 1. Go to your GitHub repository → Settings → Webhooks → Add webhook. 2. Set Payload URL to: http://your-jenkins-server.com/github-webhook/ (note the trailing slash — it is required). 3. Set Content type to 'application/json'. 4. Under 'Which events would you like to trigger this webhook?', select 'Just the push event'. 5. Check 'Active' and click Add webhook. GitHub will send a test ping immediately. In the webhook delivery history, you should see a 200 OK response from your Jenkins server. For Jenkins servers not exposed to the internet, an alternative is to use Jenkins' SCM polling (configure the pipeline to poll GitHub every N minutes). However, this is slower and less efficient than webhooks.
Pro tip: Jenkins webhook URL must be publicly accessible from GitHub's IP range. If your Jenkins is behind NAT or a private network, use a service like ngrok for development testing, or host Jenkins on a cloud VM with a public IP for production use.
Expected result: Pushing code from Replit to GitHub triggers an automatic Jenkins build. The build status appears in Jenkins within seconds of the push completing.
Monitor Builds and Surface Results Back to Your Team
Monitor Builds and Surface Results Back to Your Team
Once the webhook is active, every Replit push triggers an automatic Jenkins build. Configure Jenkins to notify your team of build results using built-in post-build actions. The most common notification setups: 1. GitHub Commit Status: Install the GitHub plugin in Jenkins, add a GitHub access token to Jenkins credentials, and add a step to update the commit status in GitHub. This shows a green checkmark or red X on every commit in GitHub. 2. Slack Notifications: Install the Slack Notification plugin in Jenkins, configure your Slack workspace integration, and add slackSend steps to your Jenkinsfile's post section. 3. Email Notifications: Jenkins has built-in email notification (Manage Jenkins → Configure System → Email Notification) that can send on failure, on recovery, or on every build. For teams using Replit as their primary dev environment, GitHub commit statuses are the most natural feedback loop — developers see build results directly in the GitHub PR interface without needing to log into Jenkins.
1// Add to your Jenkinsfile post block for GitHub status updates2post {3 success {4 // Update GitHub commit status to success5 step([$class: 'GitHubCommitStatusSetter',6 contextSource: [$class: 'ManuallyEnteredCommitContextSource',7 context: 'ci/jenkins'],8 statusResultSource: [$class: 'ConditionalStatusResultSource',9 results: [[$class: 'AnyBuildResult',10 message: 'Build passed',11 state: 'SUCCESS']]]])12 }13 failure {14 step([$class: 'GitHubCommitStatusSetter',15 contextSource: [$class: 'ManuallyEnteredCommitContextSource',16 context: 'ci/jenkins'],17 statusResultSource: [$class: 'ConditionalStatusResultSource',18 results: [[$class: 'AnyBuildResult',19 message: 'Build failed',20 state: 'FAILURE']]]])21 }22}Pro tip: Use Jenkins' Blue Ocean UI plugin for a much more readable build visualization than the classic Jenkins interface. It shows pipeline stages, test results, and logs in a clean, modern format.
Expected result: After each push from Replit, Jenkins builds the project and posts a pass/fail status to the GitHub commit. Team members see build results in GitHub without logging into Jenkins.
Common use cases
Automated Test Pipeline for Replit-Developed APIs
Every time a developer pushes code from Replit to the main branch, Jenkins automatically runs the test suite, generates a coverage report, and posts a status check back to the GitHub pull request. Developers see pass/fail in both GitHub and their Replit environment.
Set up a Jenkinsfile with stages for Install, Test, and Build. The Test stage runs 'npm test' and outputs a JUnit XML report. Configure a GitHub status webhook so build results appear as PR checks. Include environment variables for the Node version to match Replit's Node 18 runtime.
Copy this prompt to try it in Replit
Docker Build and Registry Push
Developers iterate on a Dockerized application in Replit, then push to GitHub. Jenkins picks up the push, builds the Docker image, tags it with the commit SHA, and pushes it to a container registry. The image is then available for deployment to staging or production.
Create a Jenkinsfile with stages for Checkout, Docker Build, Test, and Docker Push. Use the Jenkins Docker plugin to build a Docker image tagged with the branch name and git commit hash. Push to Docker Hub using credentials stored in Jenkins credentials manager.
Copy this prompt to try it in Replit
Deployment Pipeline with Environment Promotion
Code pushed from Replit to a feature branch triggers a Jenkins pipeline that deploys to a staging environment. After manual approval in Jenkins, the pipeline promotes the same artifact to production. This gives teams a controlled release process while keeping Replit as the development interface.
Write a Jenkinsfile with stages: Build, Deploy to Staging (automatic), Manual Approval, and Deploy to Production. Use Jenkins input step for the approval gate. Configure branch-specific behavior so only main branch pushes can reach production.
Copy this prompt to try it in Replit
Troubleshooting
Webhook delivers a 403 response from Jenkins
Cause: Jenkins has CSRF protection enabled that blocks the webhook request, or the Jenkins user associated with the webhook does not have permission to trigger builds.
Solution: In Jenkins → Manage Jenkins → Configure Global Security, check that the GitHub webhook user has 'Build' permission. Alternatively, install the GitHub plugin which handles webhook authentication correctly without requiring CSRF token exceptions.
Jenkins clones the repo but fails with 'npm: command not found' in the pipeline
Cause: Node.js is not installed on the Jenkins agent, or the Node.js tool name in the Jenkinsfile's 'tools' block does not match what is configured in Jenkins Global Tool Configuration.
Solution: Go to Jenkins → Manage Jenkins → Global Tool Configuration → NodeJS installations. Add a Node.js version and give it a name (e.g., 'NodeJS-18'). Make sure the name in your Jenkinsfile tools block matches exactly.
1// In Jenkinsfile — match this name to Jenkins Global Tool Configuration2tools {3 nodejs 'NodeJS-18' // This name must match exactly4}Pipeline triggers on every push but ignores the branch filter
Cause: The branch filter in the Jenkins pipeline job configuration uses incorrect syntax, or the GitHub plugin is not filtering branches before triggering the build.
Solution: In the Pipeline job configuration, under 'Branch Sources', add branch filters using the exact Git branch pattern. For declarative pipelines, use the 'when { branch 'main' }' condition inside specific stages to control which stages run on which branches.
1// In Jenkinsfile — only deploy on main/master branch2stage('Deploy') {3 when { branch 'main' }4 steps {5 sh 'npm run deploy'6 }7}Best practices
- Keep your Jenkinsfile in the root of your repository alongside your Replit project files — this makes the pipeline definition part of your code review process
- Use 'npm ci' instead of 'npm install' in Jenkins builds for reproducible, faster dependency installation
- Use Jenkins credentials store for all secrets needed in your pipeline (API keys, deployment tokens) — never hardcode them in the Jenkinsfile
- Set up GitHub commit status updates so Replit developers see build pass/fail directly on their commits in GitHub without needing to check Jenkins
- Use the 'cleanWs()' step in your post block to clean the Jenkins workspace after builds, preventing stale files from affecting subsequent builds
- Configure Jenkins to only build specific branches (main, develop) and use pull request builds for feature branches to avoid building every experimental push
- Archive build artifacts with 'archiveArtifacts' so successful build outputs are preserved even after workspace cleanup
Alternatives
Travis CI is a cloud-hosted CI/CD service that requires no server management, making it easier to set up than self-hosted Jenkins for teams without existing Jenkins infrastructure.
GitLab CI is tightly integrated with GitLab repositories and includes CI/CD as a built-in feature, eliminating the need for a separate Jenkins server if your team already uses GitLab.
JFrog Artifactory is complementary to Jenkins rather than an alternative — Artifactory stores the build artifacts that Jenkins produces, providing artifact management and dependency caching.
Frequently asked questions
How do I connect Replit to Jenkins?
Connect your Replit project to a GitHub repository using Replit's built-in Git panel or Settings → Connectors → GitHub. Then configure Jenkins to watch that GitHub repository using the GitHub plugin and set up a webhook in GitHub that notifies Jenkins on every push. Jenkins pulls the code and runs your Jenkinsfile pipeline automatically.
Does Jenkins run inside Replit?
No. Jenkins is a separate server that you host yourself (on a cloud VM, on-premise server, or a managed Jenkins service). Replit is the code editing and development environment. The two connect through GitHub — Replit pushes code to GitHub, and Jenkins picks it up via webhook.
Can I trigger a Jenkins build from Replit directly?
Yes. Besides webhook-triggered builds, you can trigger a Jenkins build via its REST API. Use a Jenkins API token (from Jenkins → your user → Configure → API Token) and call: curl -X POST https://your-jenkins.com/job/your-pipeline/build --user username:api-token. You could call this from a Replit shell script or a post-push Git hook.
What is a Jenkinsfile and where should it go?
A Jenkinsfile is a text file that defines your Jenkins pipeline stages and steps using Groovy-based syntax. Place it in the root directory of your repository (alongside your package.json or requirements.txt). Jenkins reads this file from your repository when a build is triggered, so your pipeline definition is version-controlled along with your code.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation