# Migrate a Jenkins Pipeline to GitHub Actions for a Maven Project

Yes. An agent reads your Jenkinsfile stage by stage, writes the equivalent GitHub Actions workflow for your Maven build, runs it in its sandbox and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/migrate-jenkins-to-github-actions/maven/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the pipeline before it writes a workflow. In a project like jenkins-docs/simple-java-maven-app, `jenkins/Jenkinsfile` is a declarative pipeline with `agent { label '!windows' }`, `options { skipStagesAfterUnstable() }` and three stages: `Build` runs `mvn -B -DskipTests clean package`, `Test` runs `mvn test` and always collects `target/surefire-reports/*.xml` with the `junit` step, and `Deliver` runs `./jenkins/scripts/deliver.sh`. That script runs `mvn jar:jar install:install help:evaluate -Dexpression=project.name`, reads the project name and version with `mvn -q -DforceStdout help:evaluate`, and finishes with `java -jar target/${NAME}-${VERSION}.jar`. `pom.xml` names `com.mycompany.app:my-app` at `1.0-SNAPSHOT`, compiles with `maven-compiler-plugin` 3.16.0 at `release` 21, sets `com.mycompany.app.App` as the jar's main class, and runs `maven-enforcer-plugin` 3.6.3 with `requireMavenVersion` `[3.9.9,)` and `requireJavaVersion` `[21,)`. The only test dependency is `junit-jupiter-api` 6.1.3. There is no `.github/workflows/` directory, only `.github/dependabot.yml` for the `maven` ecosystem, and no Maven wrapper even though `.gitignore` already keeps `.mvn/wrapper/maven-wrapper.jar`.

Then it maps each stage to a workflow step rather than translating line by line. `.github/workflows/maven.yml` runs on `push` to the default branch and on `pull_request`, with one `build` job on `ubuntu-latest`, since `!windows` excludes nothing else. `actions/checkout` and `actions/setup-java` with the Temurin distribution, Java 21 and `cache: maven` replace the Jenkins agent and its local repository volume. The three commands run as three named steps in the same order, so the stage view in the pull request reads like the Jenkins one did. `skipStagesAfterUnstable()` needs no equivalent: a failing step stops the job. The `junit` post step becomes an `if: always()` upload of `target/surefire-reports/` as an artifact plus a test-report action that annotates the pull request from the same XML. The Deliver stage keeps its three Maven commands, exports `NAME` and `VERSION` to `GITHUB_ENV`, runs the jar, and uploads `target/my-app-1.0-SNAPSHOT.jar` as a build artifact so the result is downloadable instead of printed to a Jenkins console.

The enforcer rule is the part a straight translation misses. The agent runs `mvn -v` in its sandbox and compares it with `[3.9.9,)`; because a hosted runner's Maven version is whatever the image ships, it adds the Maven wrapper with `mvn wrapper:wrapper -Dmaven=3.9.9`, commits `mvnw`, `mvnw.cmd` and `.mvn/wrapper/maven-wrapper.properties`, and uses `./mvnw` in every workflow step so the build no longer depends on the runner image. It extends `.github/dependabot.yml` with a `github-actions` ecosystem on the same weekly schedule, so the pinned actions get the updates the Maven dependencies already get.

Before opening the pull request it runs the whole sequence itself: `./mvnw -B -DskipTests clean package`, `./mvnw -B test` to confirm `target/surefire-reports/TEST-com.mycompany.app.AppTest.xml` appears with the two tests from `AppTest.java`, the deliver commands, and `java -jar` on the built jar to see the greeting `App.java` prints. It lints the workflow with `actionlint`. `jenkins/` stays in the tree, untouched, so the team can run both until the Jenkins job is retired; the pull request says so and lists what to delete afterwards.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Migrate this repository's Jenkins pipeline to GitHub Actions. Read jenkins/Jenkinsfile, jenkins/scripts/deliver.sh, pom.xml and .github/dependabot.yml first. Write .github/workflows/maven.yml that runs on push to the default branch and on pull requests, with one job on ubuntu-latest using actions/checkout and actions/setup-java (Temurin, the Java version the compiler plugin's release setting names, Maven cache). Map each Jenkins stage to named steps in the same order: the Build command, the Test command with the surefire XML uploaded as an artifact on always() and published as a test report, and the Deliver commands with the built jar uploaded as an artifact. Check the maven-enforcer-plugin's requireMavenVersion rule against mvn -v; if a hosted runner may not satisfy it, add the Maven wrapper pinned to a version that does and call ./mvnw in every step. Add a github-actions ecosystem to dependabot.yml. Run the full build, test and deliver sequence in the sandbox, run actionlint on the workflow, leave the jenkins directory in place, and open a pull request that maps each Jenkins stage to its workflow step and names what to remove once Jenkins is turned off.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request adding `.github/workflows/maven.yml`, the Maven wrapper files, and a `github-actions` entry in `.github/dependabot.yml`. The description holds a table with one row per Jenkins stage: the stage name, the command it ran, the workflow step that now runs it, and what changed, such as the `junit` post step becoming an artifact upload and a test report. A final section lists `jenkins/Jenkinsfile` and `jenkins/scripts/deliver.sh` as the files to delete when the Jenkins job is retired.

The run's record keeps the output of every Maven command the agent ran, the `mvn -v` check against the enforcer rule, the `java -jar` output and the `actionlint` result, so a reviewer can see the sequence passed in the sandbox before the workflow runs on the pull request itself.

Before merging, a reviewer confirms the workflow's first run on the pull request is green, compares the uploaded surefire report with the last Jenkins build, and decides whether the Deliver steps should run on every pull request or only on pushes to the default branch, which the pull request leaves as a one-line change.

## Run it on every repository with a Jenkinsfile

Moving one build is a hand-off; moving an organisation off Jenkins is a batch. From your own server, list the repositories that still contain a `Jenkinsfile`, and send this body once per repository to `POST /o/{org}/sessions` with that repository in `resources` and a `request_id` that is a UUID v5 of the repository's full name, so a retried call returns the run already started rather than a second pull request. Runs past the key's `max_concurrent` limit answer `202` with `status: "queued"` and start as slots free, so the loop needs no retry logic.

Set a `webhook_url` on the key and each `run.completed` event arrives with the session's `result`, which names the pull request; a `run.failed` event names the repository whose pipeline needs a person, such as one whose Jenkinsfile calls a shared library the agent cannot read.

## Why run it on Rush?

A pipeline migration fails in the details nobody reads until the first red build: an enforcer rule the runner image does not satisfy, a Maven cache that never warms, a test report that only Jenkins knew how to render. The agent runs the exact build, test and deliver commands in its own sandbox with a clean Maven repository, so a version mismatch like `[3.9.9,)` shows up before the workflow does, and the fix, a pinned wrapper, is in the same pull request.

Every command and its output stay with the run. The pull request can quote the surefire XML it produced and the jar it ran, and a reviewer compares that against the last Jenkins build instead of trusting a description of what the workflow should do.

## Frequently asked questions

### Does the agent delete the Jenkinsfile?

No. It leaves `jenkins/Jenkinsfile` and `jenkins/scripts/deliver.sh` in place so both systems can run during the cut-over, and names them in the pull request as the files to remove once the Jenkins job is disabled. A follow-up message on the same run can delete them when you are ready.

### What happens to the junit step and the test trend?

The workflow uploads `target/surefire-reports/` as an artifact on every run, including failed ones, and a test-report action turns the same XML into a check with annotations on the pull request. There is no build-over-build trend graph as in Jenkins; the artifacts keep the raw reports if you want one later.

### Why add a Maven wrapper when the runner already has Maven?

Because `maven-enforcer-plugin` requires Maven at or above 3.9.9 and a hosted runner's Maven version is set by the image, not by you. A wrapper pinned in `.mvn/wrapper/maven-wrapper.properties` makes the workflow pass on any runner and makes local builds use the same version.

### Does it handle shared libraries, credentials or parallel stages?

This pipeline has none, so the migration is direct. A Jenkinsfile that uses a shared library, `withCredentials` or `parallel` gets the same stage-by-stage mapping, with secrets named as repository secrets the workflow expects and any library step the agent cannot read listed in the pull request as needing a person.

## More Maven jobs

- [Add ArchUnit Architecture Tests to a Maven Spring Boot Project](https://getrush.ai/run/add-architecture-tests/maven/)
- [Add Checkstyle to a Maven Build](https://getrush.ai/run/add-checkstyle/maven/)
- [Add CodeQL Scanning to a Maven Spring Boot Project](https://getrush.ai/run/add-codeql-scanning/maven/)

## More jobs like this: Hand off a long task

- [Migrate a Chrome Extension from Jest to Vitest](https://getrush.ai/run/migrate-jest-to-vitest/chrome-extension/)
- [Migrate Jest to Vitest in an Electron App](https://getrush.ai/run/migrate-jest-to-vitest/electron/)
- [Migrate an Expo Project from Jest to Vitest](https://getrush.ai/run/migrate-jest-to-vitest/expo/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
