How to use the Jenkinsfile Generator
- 1. Choose the agentRun in a Docker image, on a labelled node, or on any agent.
- 2. Add commandsBuild, test, image and deploy steps; leave a box empty to skip a stage.
- 3. Commit itSave as Jenkinsfile in the repository root and point a pipeline job at it.
The default pipeline
The defaults produce 3 stages that run inside a node:24-alpine container: Checkout runs checkout scm, Build runs npm ci && npm run build, and Test runs npm test and always publishes JUnit results from reports/junit/*.xml, even when tests fail. Options add timestamps to the console, stop builds after 30 minutes, keep the last 20 builds and prevent two builds of the same branch at once.
Add an image name and the pipeline gains a Docker image stage that builds, tags with the build number and pushes using stored credentials. Add a deploy command and a Deploy stage appears; both run only on main.
Plugins and good practice
- The Docker agent and docker.build need the Docker Pipeline plugin and Docker on the agent.
junitneeds the JUnit plugin;cleanWs()needs Workspace Cleanup.when { branch 'main' }works in multibranch pipelines, where Jenkins knows the branch name.- Store registry passwords as Jenkins credentials and refer to them by ID; never type them in the file.
Commands you enter are put inside single-quoted Groovy strings with quotes escaped, so a stray apostrophe does not break the file. Generate the same CI on GitHub with the GitHub Actions workflow generator, and plan what to test with the test plan template generator.
Frequently asked questions
Declarative or scripted pipeline?
Declarative, which is the syntax Jenkins recommends for most pipelines. It is easier to read and validate.
How do I check the file before committing?
Jenkins has a declarative linter you can call through its CLI or the Pipeline Syntax pages in your Jenkins instance.
Is the Jenkinsfile Generator free?
Yes, the Jenkinsfile Generator is free. The first time you generate your first Jenkinsfile, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.