New batchZero to DevOps starts 29 Nov · limited seatsReserve your seat
Cheat sheetsJenkinsJenkins
FreeSheet 02 of 7

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 TypeDescriptionUse Case
Freestyle ProjectSimple, GUI-based configurationBasic builds, simple scripts
PipelineCode-based (Jenkinsfile)Complex CI/CD workflows
Multi-configurationMatrix buildsTesting across multiple environments
FolderOrganize jobsGroup related jobs
Multibranch PipelineAuto-create pipelines per branchBranch-based builds
GitHub OrganizationAuto-discover repositoriesGitHub-based projects
Maven ProjectSpecialized Maven buildsJava/Maven projects
External JobMonitor external jobsExternal system integration
Scripted PipelineLegacy pipeline syntaxCompatibility with older Jenkins

When to Use Which Job Type

ScenarioRecommended Job Type
Simple shell scriptFreestyle Project
Complex CI/CD pipelinePipeline (Multibranch)
Java/Maven projectMaven Project
Branch-based buildsMultibranch Pipeline
Multiple configurationsMulti-configuration
Organizing jobsFolder

Creating a Freestyle Job

Step-by-Step Creation

1. Click "New Item"

2. Enter Job Name

text
Job Name: my-app-build

3. Select "Freestyle project"

4. Click "OK"

Job Configuration Sections

SectionDescription
GeneralBasic job settings, description
Build TriggersWhen to run the job
Advanced Project OptionsQuiet period, retry count
Source Code ManagementGit, SVN, etc.
Build EnvironmentEnvironment variables, timestamps
BuildBuild steps (shell, batch, etc.)
Post-build ActionsEmail, archiving, downstream jobs

Job Configuration Example

groovy
// 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.com

Build Triggers

Available Build Triggers

TriggerDescriptionCron Syntax Example
Poll SCMPoll SCM for changesH/5 * * * * (every 5 minutes)
Build periodicallyRun on scheduleH 2 * * * (daily at 2 AM)
Build after other projectsTriggered by another jobBuild after my-app-test
GitHub hook triggerWebhook from GitHubAutomatic on push
Build when a change is pushedGit pluginAutomatic on push to Git
Remote triggerTrigger via APIcurl -X POST http://jenkins/job/build
Trigger builds remotelyToken-based triggercurl -X POST http://jenkins/job/build?token=TOKEN

Cron Syntax Cheatsheet

ExpressionMeaning
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
@dailyOnce a day
@weeklyOnce a week
@monthlyOnce a month
@midnightAt midnight
@hourlyEvery hour

API Trigger Examples

Trigger via Token:

bash
$ curl -X POST "http://localhost:8080/job/my-app-build/build?token=MY_TOKEN"

Trigger with Parameters:

bash
$ curl -X POST "http://localhost:8080/job/my-app-build/buildWithParameters?BRANCH=develop"

Trigger with API Token:

bash
$ curl -X POST "http://localhost:8080/job/my-app-build/build?token=MY_TOKEN" --user admin:api_token

Build Steps

Available Build Step Types

Step TypePurposeExample
Execute shellRun shell script#!/bin/bash
Execute Windows batchRun batch scriptecho Hello
Invoke AntRun Ant buildbuild.xml
Invoke GradleRun Gradle buildgradle build
Invoke MavenRun Maven buildmvn clean install
Invoke top-level MavenMaven with optionsmvn -P prod deploy
Run Groovy ScriptRun Groovy scriptInline or file
Trigger other jobsTrigger downstreamBuild my-app-deploy
Copy artifactsCopy from another jobFrom my-app-build
Execute NodeJS scriptRun Node.jsnpm install
Docker build/publishDocker stepsBuild and push image

Common Build Step Examples

Shell Script:

bash
#!/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:

bash
mvn clean install -DskipTests=false -P production

Docker Build:

bash
docker build -t myapp:$BUILD_NUMBER .
docker push myapp:$BUILD_NUMBER

Git Operations:

bash
git checkout $BRANCH_NAME
git pull origin $BRANCH_NAME
git tag v$BUILD_NUMBER
git push origin v$BUILD_NUMBER

Python Script:

bash
python -m pip install -r requirements.txt
python -m pytest tests/

Post-Build Actions

Available Post-Build Actions

ActionPurposeConfiguration
Archive the artifactsSave build artifacts**/dist/**, **/*.jar
Publish JUnit test resultTest results**/test-results/*.xml
Email notificationSend emailRecipients, subject
Build other projectsTrigger downstreamProject name
Publish HTML reportsHTML reportsReport directory
Git publisherGit operationsPush, tag, commit
Set build descriptionAdd descriptionBuild ${BUILD_NUMBER}
Set GitHub commit statusGitHub integrationStatus updates
Publish artifacts to S3AWS S3 uploadBucket, region
Deploy to CloudFormationAWS CDStack name
Deploy to KubernetesK8s deploymentManifest file

Post-Build Action Examples

Archive Artifacts:

text
Files to archive: **/target/*.jar, **/dist/**
Excludes: **/*-sources.jar

Publish Test Results:

text
Test report XMLs: **/test-results/*.xml
Retain long standard output: 1000 lines

Trigger Downstream Job:

text
Project to build: my-app-deploy
Trigger when: Stable or Unstable
Block until completion: yes

Email Notification:

text
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

groovy
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

TaskCommand
Create freestyle jobNew Item → Freestyle Project
Schedule a buildBuild Trigger → Poll SCM or Build periodically
Add shell scriptBuild → Add build step → Execute shell
Archive artifactsPost-build Actions → Archive the artifacts
Publish test resultsPost-build Actions → Publish JUnit test result report
Trigger downstreamPost-build Actions → Build other projects
Build via APIcurl -X POST http://jenkins/job/my-job/build
Build with parameterscurl -X POST http://jenkins/job/my-job/buildWithParameters?PARAM=value

Pro Tips

  1. Use set -e in shell scripts — exit on first error.

  2. Poll SCM is inefficient — use webhooks (GitHub hook trigger) instead.

  3. Archive artifacts — essential for debugging failed builds.

  4. Keep builds clean — use "Discard old builds" to save disk space.

  5. Use parameters — for reusable jobs (Branch, Environment).

  6. Console output is your friend — add timestamps to track timing.

  7. Test report parsing — ensures JUnit/TestNG reports are in correct format.

  8. Environment variables — use $BUILD_NUMBER, $JOB_NAME for versioning.


** Part 2 of 8 — Jenkins Job Types & Freestyle Jobs** DevOps Training Platform · Jenkins Series


Last Updated: 2026 · Compatible with Jenkins 2.x

text

---

##  **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!
Next in JenkinsJenkins Pipeline
Jenkins cheat sheet: Job Types & Freestyle Jobs | InfraThrone DevOps Park