Ravindra BagaleCourses & study guides मराठी

Chapter 20: Jenkins Manual Jobs — Install, Configure and Freestyle

Chala mitrano, aaj aapan Jenkins pehle click-click (Freestyle) ne. Install, plugins, Git, webhook vs poll, aani Node.js Freestyle job: Develop → Build → Test → lab Live. Pipeline code pudhchya chapter madhe. Ghabru naka.

What you will learn in this chapter

  • Install Jenkins LTS on Linux without inventing package URLs
  • Plugins, tools, Jenkins URL and executors
  • Wire Git into a Freestyle job
  • Honest webhook vs poll SCM for a laptop lab
  • Develop → build → test → lab live on a Node.js Freestyle project
  • Parameters, archive, email, and upstream or downstream jobs
  • Read a green ball and a red Console Output

Concepts in this chapter

  1. 20.1Why a Freestyle job still matters
  2. 20.2Install Jenkins LTS on Linux (honest flow)
  3. 20.3First UI: suggested plugins and safety
  4. 20.4Plugins you actually need for this lab
  5. 20.5Configuration: URL, executors, quiet period
  6. 20.6Tools: Git and Node locations
  7. 20.7Credentials for private Git (by ID only)
  8. 20.8Git integration in a Freestyle project
  9. 20.9Webhook vs poll SCM (honest lab)
  10. 20.10Tiny Node.js project shape (what Jenkins needs)
  11. 20.11Freestyle build steps — Node.js manual job
  12. 20.12Post-build and reading a red build
  13. 20.13Freestyle checklist for interviews
  14. 20.14Parameters on the Freestyle job
  15. 20.15Archive and email after the build
  16. 20.16Upstream and downstream
  17. 20.17Triggers side by side

The chapter recap is at the end of the last concept page.

Practice Tasks

About this scenario

Suppose we are on the DevOps team at Spotify, the music streaming company, working from Stockholm. Elsa Lindqvist leads the team, and we look after the playlist service. Costs are counted in SEK. In the tasks below we do real DevOps jobs on this project using what this lesson teaches. Spotify is a real company, but this project, the people, servers, IP addresses and numbers are made up for practice.

0 / 12

Easy Declarative Jenkinsfile: build and test

Why: Pipeline as code lives in Git with the app, so every change is reviewed.

What to do: Write a declarative Jenkinsfile: agent any; stage Build runs sh 'mvn -B package'; stage Test runs sh 'mvn test'.

How:
  1. Start with pipeline { and close it with } at the end.
  2. Add agent, then stages { } with one stage('Name') { steps { } } per step.
  3. Put the commands inside steps using sh '...'.
  4. Count your { and } so every block is closed, then click Check answer.

Easy Name the practice

Why: Knowing the names helps you in interviews and design talks.

What to do: At Spotify every developer merges small changes into main several times a day, and each merge is built and tested automatically. What is this practice called (two-letter short form)?

How:
  1. Write down the facts or numbers the task gives you.
  2. Work it out step by step.
  3. Type only the final answer (one word or number) in the box.
  4. Click Check answer.

Medium Run the build inside a Docker agent

Why: A Docker agent gives a clean, versioned toolchain for every build.

What to do: Declarative pipeline with agent docker { image 'maven:3.9-eclipse-temurin-21' } and stage Build running sh 'mvn -B verify'.

How:
  1. Start with pipeline { and close it with } at the end.
  2. Add agent, then stages { } with one stage('Name') { steps { } } per step.
  3. Put the commands inside steps using sh '...'.
  4. Count your { and } so every block is closed, then click Check answer.

Medium Pipeline environment variables

Why: Values set once in environment are reused by every stage.

What to do: Declarative pipeline, agent any, environment with IMAGE = 'spotify/playlist' and TAG = '1.5.2', and stage Image running sh 'docker build -t $IMAGE:$TAG .'.

How:
  1. Start with pipeline { and close it with } at the end.
  2. Add agent, then stages { } with one stage('Name') { steps { } } per step.
  3. Put the commands inside steps using sh '...'.
  4. Count your { and } so every block is closed, then click Check answer.

Medium Always archive, alert on failure

Why: post blocks run after the stages, whatever the result.

What to do: Declarative pipeline, agent any, one stage Build with sh 'make'. Add post: always → archiveArtifacts artifacts: 'build/**'; failure → echo 'Build failed'.

How:
  1. Start with pipeline { and close it with } at the end.
  2. Add agent, then stages { } with one stage('Name') { steps { } } per step.
  3. Put the commands inside steps using sh '...'.
  4. Count your { and } so every block is closed, then click Check answer.

Medium Deploy only from main

Why: Feature branches are built and tested but never deployed.

What to do: Declarative pipeline, agent any, stage Deploy with when { branch 'main' } and steps sh './deploy.sh eu-north-1'.

How:
  1. Start with pipeline { and close it with } at the end.
  2. Add agent, then stages { } with one stage('Name') { steps { } } per step.
  3. Put the commands inside steps using sh '...'.
  4. Count your { and } so every block is closed, then click Check answer.

Medium Delivery or deployment?

Why: The two words mean different levels of automation.

What to do: At Spotify every change that passes tests goes to production automatically, with no human approval. Is this continuous delivery or continuous deployment? Type one word.

How:
  1. Write down the facts or numbers the task gives you.
  2. Work it out step by step.
  3. Type only the final answer (one word or number) in the box.
  4. Click Check answer.

Medium Run only for main and pull requests

Why: Limiting triggers saves CI minutes and noise.

What to do: Write a workflow named Build whose on: runs for push to branch main and for pull_request to branch main. One job build on ubuntu-latest with a single step run: make build.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Hard Use Jenkins credentials safely

Why: withCredentials masks the password and removes it after the block.

What to do: Inside stage Push steps, use withCredentials with usernamePassword(credentialsId: 'reg-cred', usernameVariable: 'U', passwordVariable: 'P') and run sh 'echo $P | docker login -u $U --password-stdin registry.spotify.example.com'. Wrap it in a full declarative pipeline with agent any.

How:
  1. Start with pipeline { and close it with } at the end.
  2. Add agent, then stages { } with one stage('Name') { steps { } } per step.
  3. Put the commands inside steps using sh '...'.
  4. Count your { and } so every block is closed, then click Check answer.

Hard Manual approval before production

Why: A human sign-off stops an accidental production release.

What to do: Declarative pipeline, agent any, stage Prod with input message 'Deploy to production?' and steps sh './deploy.sh prod'.

How:
  1. Start with pipeline { and close it with } at the end.
  2. Add agent, then stages { } with one stage('Name') { steps { } } per step.
  3. Put the commands inside steps using sh '...'.
  4. Count your { and } so every block is closed, then click Check answer.

Hard Parallel test stages

Why: Running unit and lint at the same time halves feedback time.

What to do: Declarative pipeline, agent any, stage Checks containing parallel with stage Unit (sh 'npm test') and stage Lint (sh 'npm run lint').

How:
  1. Start with pipeline { and close it with } at the end.
  2. Add agent, then stages { } with one stage('Name') { steps { } } per step.
  3. Put the commands inside steps using sh '...'.
  4. Count your { and } so every block is closed, then click Check answer.

Hard Name the approach

Why: GitOps tools like Argo CD are now common in K8s teams.

What to do: At Spotify a tool inside the cluster keeps pulling manifests from a Git repo and makes the cluster match it. What is this approach called (one word)?

How:
  1. Write down the facts or numbers the task gives you.
  2. Work it out step by step.
  3. Type only the final answer (one word or number) in the box.
  4. Click Check answer.

Ravi Sir's Cards: 37 revision, interview and comparison cards for this chapter · मराठी cards