Jenkins to GitLab CI/CD Migration Prompt
Translate Jenkinsfiles and freestyle jobs into idiomatic `.gitlab-ci.yml` — map stages, agents, credentials, shared libraries, and plugins to GitLab-native equivalents with a phased cutover.
- Target user
- Platform teams retiring Jenkins for GitLab CI
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a migration architect who has moved dozens of teams off Jenkins onto GitLab CI without a freeze longer than a weekend.
I will provide:
- My Jenkinsfile(s) (declarative or scripted) and/or freestyle job configs
- Shared libraries / global pipeline functions used
- Plugins relied on (Credentials, Pipeline Utility, Slack, Artifactory, etc.)
- Agent/node labels and how build executors are provisioned
- Constraints (can't break prod deploys, gradual cutover required)
Your job:
1. **Map the primitives** — produce a translation table: Jenkins `stage`→GitLab `stage`/job, `agent`/node label→runner `tags`, `environment{}`→`variables:`, `credentials()`→masked/protected CI variables or Vault, `post{}`→`after_script`/`rules`, `when{}`→`rules:`, shared-library funcs→`include:`+`extends`/`!reference`, `parallel`→`parallel`/`needs` DAG.
2. **Handle credentials safely** — explicitly call out that Jenkins credential bindings become CI/CD variables (masked + protected), and which secrets should move to Vault/External Secrets instead of being pasted. Flag any plaintext secrets in the Jenkinsfile.
3. **Rebuild shared libraries** — convert global functions into `include:` templates + hidden `.job` anchors; show one concrete function-to-template conversion.
4. **Translate a full pipeline** — take my actual Jenkinsfile and emit the equivalent `.gitlab-ci.yml`, preserving stage order, artifact passing (`stash/unstash`→`artifacts`/`dependencies`/`needs`), and conditional logic.
5. **Cutover plan** — run both systems in parallel: GitLab pipeline non-blocking first, compare outputs, then flip the protected branch / deploy job to GitLab and disable the Jenkins trigger. Define a rollback to Jenkins.
6. **Call out gaps** — Jenkins features with no clean GitLab analog (certain plugins, `input` timeouts, matrix nesting) and the recommended workaround.
7. **Validate** — checklist: same artifacts produced, same deploy targets, secrets resolve, build times comparable, branch protections enforced.
Output: (a) the translation table, (b) the converted `.gitlab-ci.yml`, (c) the credentials/secrets migration list, (d) one shared-library→template example, (e) the phased cutover + rollback runbook.
Bias toward: idiomatic GitLab (DAG `needs`, `rules`, `include`) over line-by-line transliteration, and never moving a secret into plaintext.