Job Types & Freestyle Jobs
A comprehensive developer cheatsheet covering Jenkins job types and Freestyle project configuration, featuring essential workflows for build triggers, cron schedules, build steps, and post-build actions.
Jenkins Job Types Overview
Available Job Types
| Job Type | Description | Use Case |
|---|---|---|
| Freestyle Project | Simple, GUI-based configuration | Basic builds, simple scripts |
| Pipeline | Code-based (Jenkinsfile) | Complex CI/CD workflows |
| Multi-configuration | Matrix builds | Testing across multiple environments |
| Folder | Organize jobs | Group related jobs |
| Multibranch Pipeline | Auto-create pipelines per branch | Branch-based builds |
| GitHub Organization | Auto-discover repositories | GitHub-based projects |
| Maven Project | Specialized Maven builds | Java/Maven projects |
| External Job | Monitor external jobs | External system integration |
| Scripted Pipeline | Legacy pipeline syntax | Compatibility with older Jenkins |
When to Use Which Job Type
| Scenario | Recommended Job Type |
|---|---|
| Simple shell script | Freestyle Project |
| Complex CI/CD pipeline | Pipeline (Multibranch) |
| Java/Maven project | Maven Project |
| Branch-based builds | Multibranch Pipeline |
| Multiple configurations | Multi-configuration |
| Organizing jobs | Folder |
Creating a Freestyle Job
Step-by-Step Creation
1. Click "New Item"
2. Enter Job Name
Job Name: my-app-build3. Select "Freestyle project"
4. Click "OK"
Job Configuration Sections
| Section | Description |
|---|---|
| General | Basic job settings, description |
| Build Triggers | When to run the job |
| Advanced Project Options | Quiet period, retry count |
| Source Code Management | Git, SVN, etc. |
| Build Environment | Environment variables, timestamps |
| Build | Build steps (shell, batch, etc.) |
| Post-build Actions | Email, archiving, downstream jobs |
Job Configuration Example
// General
Description: "Build my application"
// Source Code Management
Git Repository: https://github.com/myuser/myapp.git
Branch: */main
// Build Triggers
Poll SCM: H/5 * * * *
GitHub hook trigger for GITScm polling
// Build Environment
Delete workspace before build starts
Add timestamps to the Console Output
// Build
Execute shell:
#!/bin/bash
echo "Building application..."
npm install
npm run build
// Post-build Actions
Archive the artifacts: **/dist/**
Publish JUnit test result report: **/test-results/*.xml
Email notification: admin@example.comBuild Triggers
Available Build Triggers
| Trigger | Description | Cron Syntax Example |
|---|---|---|
| Poll SCM | Poll SCM for changes | H/5 * * * * (every 5 minutes) |
| Build periodically | Run on schedule | H 2 * * * (daily at 2 AM) |
| Build after other projects | Triggered by another job | Build after my-app-test |
| GitHub hook trigger | Webhook from GitHub | Automatic on push |
| Build when a change is pushed | Git plugin | Automatic on push to Git |
| Remote trigger | Trigger via API | curl -X POST http://jenkins/job/build |
| Trigger builds remotely | Token-based trigger | curl -X POST http://jenkins/job/build?token=TOKEN |
Cron Syntax Cheatsheet
| Expression | Meaning |
|---|---|
H/5 * * * * | Every 5 minutes |
H/15 * * * * | Every 15 minutes |
H * * * * | Every hour |
H H * * * | Once a day |
H H(0-2) * * * | Between 12 AM and 2 AM |
H H 1 * * | First day of every month |
@daily | Once a day |
@weekly | Once a week |
@monthly | Once a month |
@midnight | At midnight |
@hourly | Every hour |
API Trigger Examples
Trigger via Token:
$ curl -X POST "http://localhost:8080/job/my-app-build/build?token=MY_TOKEN"Trigger with Parameters:
$ curl -X POST "http://localhost:8080/job/my-app-build/buildWithParameters?BRANCH=develop"Trigger with API Token:
$ curl -X POST "http://localhost:8080/job/my-app-build/build?token=MY_TOKEN" --user admin:api_tokenBuild Steps
Available Build Step Types
| Step Type | Purpose | Example |
|---|---|---|
| Execute shell | Run shell script | #!/bin/bash |
| Execute Windows batch | Run batch script | echo Hello |
| Invoke Ant | Run Ant build | build.xml |
| Invoke Gradle | Run Gradle build | gradle build |
| Invoke Maven | Run Maven build | mvn clean install |
| Invoke top-level Maven | Maven with options | mvn -P prod deploy |
| Run Groovy Script | Run Groovy script | Inline or file |
| Trigger other jobs | Trigger downstream | Build my-app-deploy |
| Copy artifacts | Copy from another job | From my-app-build |
| Execute NodeJS script | Run Node.js | npm install |
| Docker build/publish | Docker steps | Build and push image |
Common Build Step Examples
Shell Script:
#!/bin/bash
set -e
echo "Building application..."
npm install
npm run build
echo "Running tests..."
npm test
echo "Creating artifact..."
tar -czf app.tar.gz dist/Maven Build:
mvn clean install -DskipTests=false -P productionDocker Build:
docker build -t myapp:$BUILD_NUMBER .
docker push myapp:$BUILD_NUMBERGit Operations:
git checkout $BRANCH_NAME
git pull origin $BRANCH_NAME
git tag v$BUILD_NUMBER
git push origin v$BUILD_NUMBERPython Script:
python -m pip install -r requirements.txt
python -m pytest tests/Post-Build Actions
Available Post-Build Actions
| Action | Purpose | Configuration |
|---|---|---|
| Archive the artifacts | Save build artifacts | **/dist/**, **/*.jar |
| Publish JUnit test result | Test results | **/test-results/*.xml |
| Email notification | Send email | Recipients, subject |
| Build other projects | Trigger downstream | Project name |
| Publish HTML reports | HTML reports | Report directory |
| Git publisher | Git operations | Push, tag, commit |
| Set build description | Add description | Build ${BUILD_NUMBER} |
| Set GitHub commit status | GitHub integration | Status updates |
| Publish artifacts to S3 | AWS S3 upload | Bucket, region |
| Deploy to CloudFormation | AWS CD | Stack name |
| Deploy to Kubernetes | K8s deployment | Manifest file |
Post-Build Action Examples
Archive Artifacts:
Files to archive: **/target/*.jar, **/dist/**
Excludes: **/*-sources.jarPublish Test Results:
Test report XMLs: **/test-results/*.xml
Retain long standard output: 1000 linesTrigger Downstream Job:
Project to build: my-app-deploy
Trigger when: Stable or Unstable
Block until completion: yesEmail Notification:
Recipients: team@example.com
Subject: Build ${BUILD_NUMBER} ${JOB_NAME} - ${BUILD_STATUS}
Content: https://jenkins.example.com/job/${JOB_NAME}/${BUILD_NUMBER}Example Complete Freestyle Job Configuration
Job: my-app-build
General
- Description: Build and test my Node.js application
- Discard old builds
- Strategy: Log Rotation
- Days to keep builds: 7
- Max # of builds to keep: 10
Source Code Management
- Git: https://github.com/myuser/myapp.git
- Branch: */main
- Credentials: github-credentials
Build Triggers
- Poll SCM: H/5 * * * *
- GitHub hook trigger for GITScm polling
Build Environment
- Delete workspace before build starts
- Add timestamps to the Console Output
- Set environment variables: NODE_ENV=production
Build
- Execute shell:
#!/bin/bash
npm install
npm run build
npm test
tar -czf app.tar.gz dist/
Post-build Actions
- Archive the artifacts: app.tar.gz
- Publish JUnit test result report: test-results/*.xml
- Email notification: team@example.com
- Set build description: Build ${BUILD_NUMBER} - ${BUILD_STATUS}Quick Reference — Most Used Commands
| Task | Command |
|---|---|
| Create freestyle job | New Item → Freestyle Project |
| Schedule a build | Build Trigger → Poll SCM or Build periodically |
| Add shell script | Build → Add build step → Execute shell |
| Archive artifacts | Post-build Actions → Archive the artifacts |
| Publish test results | Post-build Actions → Publish JUnit test result report |
| Trigger downstream | Post-build Actions → Build other projects |
| Build via API | curl -X POST http://jenkins/job/my-job/build |
| Build with parameters | curl -X POST http://jenkins/job/my-job/buildWithParameters?PARAM=value |
Pro Tips
-
Use
set -ein shell scripts — exit on first error. -
Poll SCM is inefficient — use webhooks (GitHub hook trigger) instead.
-
Archive artifacts — essential for debugging failed builds.
-
Keep builds clean — use "Discard old builds" to save disk space.
-
Use parameters — for reusable jobs (Branch, Environment).
-
Console output is your friend — add timestamps to track timing.
-
Test report parsing — ensures JUnit/TestNG reports are in correct format.
-
Environment variables — use
$BUILD_NUMBER,$JOB_NAMEfor versioning.
** Part 2 of 8 — Jenkins Job Types & Freestyle Jobs** DevOps Training Platform · Jenkins Series
Last Updated: 2026 · Compatible with Jenkins 2.x
---
## **What's Covered in Part 2:**
| Topic | Description |
| :--- | :--- |
| **Job Types Overview** | Freestyle, Pipeline, Maven, Multibranch, etc. |
| **Freestyle Job** | Step-by-step creation, configuration sections |
| **Build Triggers** | Poll SCM, Periodic, Webhook, Remote trigger, cron syntax |
| **Build Steps** | Shell, Maven, Docker, Git, Python |
| **Post-Build Actions** | Archive artifacts, publish tests, email, downstream jobs |
| **Complete Example** | Full freestyle job configuration |
| **Quick Reference** | 7 most-used tasks |
| **Pro Tips** | set -e, webhooks, archive artifacts, console output |
---
## **Ready for Part 3?**
Just say **"continue"** and I'll drop **Part 3: Jenkins Pipeline (Declarative & Scripted)** next!
---
**GitHub Actions** — I'll create the GitHub Actions series separately after completing Jenkins. Let me know if you want it interleaved or after!