Connect a Git repo
In a freestyle (or Pipeline) job:
- Source Code Management → Git
- Repository URL (HTTPS or SSH)
- Credentials (PAT or SSH key from Day 2)
- Branch specifier:
*/main
Install Git plugin / GitHub plugin if missing (Manage Jenkins → Plugins).
Build triggers
| Trigger | Behavior |
|---|---|
| GitHub hook trigger | Instant build on push (webhook) |
| Poll SCM | Jenkins checks Git on a schedule |
| Build periodically | Cron schedule (H/15 * * * *) |
| Upstream | After another job finishes |
| Manual | Build Now |
Webhook vs poll
Webhook: GitHub → Jenkins (push event) ← preferred
Poll SCM: Jenkins → GitHub (every N minutes)
Webhooks are faster and lighter. Polling is a fallback when webhooks are hard (firewall, no public URL).
Cron tips
Jenkins uses a cron-like syntax; H means “hash” to spread load:
H/15 * * * * # roughly every 15 minutes
H 2 * * * # once a day around 02:00
Multibranch preview
Multibranch Pipeline jobs discover branches/PRs that contain a Jenkinsfile and create a job per branch. You will write that Jenkinsfile on Day 3.
For local Jenkins without a public URL, use Poll SCM or a tunnel (ngrok) for webhooks during labs.