Opscraft
Jenkins · Lesson 3 of 11 · 3 min read

Jobs, triggers and build history

Job types

Type What it is Use today
Freestyle Configured through UI forms; shell steps, post-build actions Legacy; avoid for new work — not versioned, not reviewable
Pipeline Defined by a Jenkinsfile (inline or from SCM) Single-branch pipelines
Multibranch Pipeline Scans a repo and creates a pipeline per branch and pull request containing a Jenkinsfile Standard for application repos
Organization Folder Scans a GitHub org / Bitbucket project and creates multibranch jobs for every repo with a Jenkinsfile Platform teams onboarding many repos automatically

Multibranch gives you env.BRANCH_NAME, env.CHANGE_ID (PR number) and when { changeRequest() }, and reports status checks back to GitHub.

Triggers

  • Webhooks (GitHub/GitLab/Bitbucket push and PR events → Jenkins) — instant and efficient. Requires the controller to be reachable from the SCM (or a relay like smee/webhook proxy).
  • Poll SCM (pollSCM('H/5 * * * *')) — Jenkins asks the repo for changes on a schedule. Wastes resources at scale; a fallback when webhooks can't reach Jenkins.
  • cron (cron('H 2 * * *')) — time-based (nightly builds, scans).
  • Upstream/downstream — build job: 'deploy-orders', parameters: [string(name: 'TAG', value: sha)], wait: false, or upstream(upstreamProjects: 'lib-common', threshold: hudson.model.Result.SUCCESS).
  • Remote trigger via REST API with an API token.

The H in Jenkins cron means "hash": H 2 * * * picks a stable minute within 02:00–02:59 per job, spreading load instead of starting 300 jobs at exactly 02:00.

Enlarge diagramWebhookpollSCMGitHub calls Jenkins on push or PRStarts in secondsJenkins must be reachable (or use a relay)Jenkins asks every few minutesWastes resources at scaleFallback only
Figure 1. Webhooks push events to Jenkins instantly; polling makes Jenkins ask every repository on a timer.
Swipe sideways to see all of it, or tap to open it full screen.

Parameters

String, choice, boolean, password, and more via plugins (Active Choices). Read as params.NAME. Parameterised builds are how you implement "deploy version X to environment Y" jobs — but in GitOps setups, deployments happen through Git commits instead.

Build retention and artifacts

options { buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '5')) }

Without retention, JENKINS_HOME grows forever — the most common cause of controller disk incidents. Archive only what you need (archiveArtifacts artifacts: 'build/*.zip', fingerprint: true); store real release artifacts in a repository (Nexus, Artifactory, S3, ECR), not in Jenkins. stash/unstash pass small files between stages on different agents within one run (they go through the controller — keep them small).