Jenkins Freestyle Jobs Explained
A Freestyle job is the simplest type of job in Jenkins. You configure it entirely through a web form — no code required. It is the best starting point for beginners learning Jenkins.
Think of a Freestyle job as filling out an online form. You answer questions about what to do, when to do it, and what to do with the result. Jenkins follows those instructions every time the job runs.
When to Use a Freestyle Job
Freestyle jobs work well for simple tasks. They are ideal when you need to run a shell script, execute a build command, or connect a single Git repository to a single build step.
For complex workflows with multiple stages, use Pipelines instead (covered later in this course). For now, Freestyle jobs give you a solid foundation.
Creating Your First Freestyle Job
Step 1: Click "New Item" on the Dashboard
Step 2: Enter a name for your job
(e.g., "my-first-build")
Step 3: Select "Freestyle project"
Step 4: Click "OK"
Step 5: Configure the job (see sections below)
Step 6: Click "Save"
Freestyle Job Configuration Sections
The configuration page for a Freestyle job has six main sections. Each section controls one aspect of the job's behavior.
Configuration Page Map
+------------------------------------------+ | 1. General | | Description, discard old builds, | | parameters, restrict to node | +------------------------------------------+ | 2. Source Code Management (SCM) | | Git / SVN repo URL, credentials, | | branch to build | +------------------------------------------+ | 3. Build Triggers | | When should this job run? | | (Schedule, GitHub push, manual) | +------------------------------------------+ | 4. Build Environment | | Delete workspace before build, | | use secret text/files, timestamps | +------------------------------------------+ | 5. Build Steps | | Commands to execute | | (Shell script, batch command, | | invoke Maven, Ant, Gradle) | +------------------------------------------+ | 6. Post-Build Actions | | What to do after the build | | (Send email, archive files, | | trigger another job) | +------------------------------------------+
Section 1: General Settings
The General section holds settings that apply to the whole job.
Description: Write a short explanation of what this job does. This helps teammates understand the job's purpose without opening the configure page.
Discard Old Builds: Jenkins keeps a log of every build. Over time, this uses a lot of disk space. Set a maximum number of days or builds to keep. For example, keep only the last 10 builds.
This project is parameterized: Add variables that users can fill in when they trigger the job manually. For example, a parameter called ENVIRONMENT could accept values like staging or production.
Section 2: Source Code Management
This is where you tell Jenkins where your code lives. Most teams use Git. Enter the repository URL, the credentials to access it, and the branch name.
Repository URL: https://github.com/your-org/your-repo.git Credentials: Select saved credentials (username + password or SSH key) Branch: */main OR */develop
When Jenkins runs the job, it checks out the latest code from this branch and puts it in the workspace — a temporary folder on the build machine.
Section 3: Build Triggers
Build triggers define when the job runs. You can leave it manual, or set it to run automatically.
| Trigger Option | What It Does |
|---|---|
| Build periodically | Runs on a time schedule (like a cron job) |
| Poll SCM | Jenkins checks Git for changes on a schedule and builds if changes found |
| GitHub hook trigger | GitHub sends a signal to Jenkins when code is pushed |
| Trigger builds remotely | An external system calls a Jenkins URL to start the job |
| Build after other projects | This job runs automatically when another job finishes |
Section 4: Build Steps
Build steps are the actual commands Jenkins runs. This is the core of the job. Click "Add build step" to choose from available options.
Common Build Step Types
Execute shell (Linux/Mac):
→ Run any shell command
→ Example: mvn clean install
npm test
python manage.py test
Execute Windows batch command:
→ Run any .bat or cmd command
→ Example: npm install
gradle build
Invoke top-level Maven targets:
→ Maven-specific option
→ Enter goals: clean package test
Invoke Ant:
→ Ant build tool for Java projects
Execute Groovy script:
→ Run a Groovy script inline
Section 5: Post-Build Actions
Post-build actions run after the main build steps finish. They handle reporting, notifications, and chained actions.
Archive the artifacts:
→ Save output files (JARs, logs, reports)
→ Example: target/*.jar
test-results/**/*.xml
Publish JUnit test result report:
→ Jenkins reads XML test results and shows pass/fail counts
Email Notification:
→ Send emails to developers when the build fails or recovers
Trigger parameterized build on other projects:
→ Automatically start the next job in a chain
Build other projects:
→ Run another Jenkins job after this one finishes
A Real-World Freestyle Job Example
Imagine a Java web application stored in a Git repository. You want Jenkins to build and test it automatically whenever a developer pushes code.
Job Name: java-webapp-build
Source Code Management:
Git URL: https://github.com/myteam/webapp.git
Branch: */main
Build Trigger:
GitHub hook trigger for GITScm polling
Build Step:
Invoke top-level Maven targets
Goals: clean test package
Post-Build Actions:
Publish JUnit test result report
Test report XMLs: target/surefire-reports/*.xml
Archive the artifacts
Files: target/*.war
Email Notification
Notify: developer@mycompany.com
Key Points
- Freestyle jobs are configured through a web form — no code needed.
- The configuration page has six sections: General, SCM, Build Triggers, Build Environment, Build Steps, and Post-Build Actions.
- Build steps contain the commands Jenkins runs — shell scripts, Maven, Gradle, and more.
- Post-build actions handle what happens after the build: saving files, sending emails, or triggering other jobs.
- Freestyle jobs are best for simple tasks; use Pipelines for complex multi-stage workflows.
