Skip to content

Git, Maven and Jenkins Interview Questions for Automation Testing

34 Git, Maven and Jenkins questions with answers for automation testing roles — 10 easy, 20 medium, 4 hard.

About Git, Maven and Jenkins

Covers the tooling around automation code: Git branching, merging, rebasing and conflict handling; Maven lifecycle, Surefire, profiles and dependencies; and Jenkins pipelines, triggers, credentials, parallel stages and reporting. Interviewers expect you to run your suite from the command line and in CI, not only from the IDE.

Sheet progressStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
3 questions free Unlock the rest in seconds
01

What is the difference between git fetch and git pull?

Save to ▾
Show answer
git fetch downloads new commits and branches from the remote but does not change your working files; you can inspect them with git log origin/main. git pull is fetch followed by merge (or rebase if configured) into your current branch. Fetch is safer when you want to review changes before integrating them.
02

How do you resolve a merge conflict in Git?

Save to ▾
Show answer
Git marks conflicting sections with <<<<<<<, ======= and >>>>>>>. Open each file, decide which change to keep or combine both, remove the markers, then git add the files and complete with git commit (or git rebase --continue). Run the affected tests before pushing. Pull often and keep branches short-lived to reduce conflicts.
03

What is a .gitignore file and what should an automation project ignore?

Save to ▾
Show answer
A .gitignore lists files Git should not track. In a Java automation project ignore target/, test-output/, allure-results/, reports, screenshots, logs, IDE folders like .idea and .vscode, *.iml, OS files like .DS_Store, and local config files holding secrets. Ignoring generated output keeps the repository small and avoids noisy diffs and conflicts.
04

What is git stash and when would you use it?

Save to ▾
Show answer
git stash saves uncommitted changes and cleans the working directory so you can switch branches. Later, git stash pop reapplies them. Use it when you are halfway through a change and must quickly fix something on another branch. git stash list shows saved stashes, and git stash push -m "msg" names them. For longer work, a temporary commit on a branch is clearer.
05

What is the Maven build lifecycle?

Save to ▾
Show answer
The default lifecycle has phases in order: validate, compile, test, package, verify, install and deploy. Running a phase runs all earlier phases too, so mvn test compiles and then runs unit tests through Surefire. mvn verify also runs integration tests with Failsafe. There are also clean and site lifecycles. Automation suites usually run with mvn clean test or mvn clean verify.
06

How do you pass parameters like browser and environment from Maven to your tests?

Save to ▾
Show answer
Pass system properties on the command line, for example mvn test -Dbrowser=firefox -Denv=qa. Read them in Java with System.getProperty("browser", "chrome"), giving a default. Surefire forwards -D properties to the forked test JVM, or you can declare them under systemPropertyVariables. Jenkins can expose these as build parameters so testers choose browser and environment per run.
07

How do you trigger a Jenkins job automatically?

Save to ▾
Show answer
Common triggers are webhooks from GitHub, GitLab or Bitbucket on push or pull request, cron schedules with triggers { cron('H 2 * * *') } for nightly regression, polling SCM (less efficient), and upstream jobs completing, such as running tests after a deploy job. Multibranch pipelines automatically create jobs for each branch and pull request containing a Jenkinsfile.
08

What is the post section in a Jenkins declarative pipeline?

Save to ▾
Show answer
post defines steps that run after stages based on the result: always, success, failure, unstable, changed, fixed and cleanup. In test pipelines, always publishes JUnit results and archives screenshots and reports, failure sends a Slack or email alert, and cleanup removes the workspace. Putting reporting in post ensures results are saved even when tests fail.
09

What does a good commit message look like?

Save to ▾
Show answer
A short summary line under about 60 characters in the imperative mood, like "Add retry for flaky payment test", followed by a blank line and a body explaining why the change was made if not obvious. Reference the ticket ID. Small focused commits with clear messages make reviews faster and help when using git log or git bisect to find when a test broke.
10

What is a Jenkins agent and how do labels help run tests?

Save to ▾
Show answer
An agent is a machine or container that runs build steps on behalf of the Jenkins controller. Labels are tags given to agents, such as linux, docker or windows-chrome. In a pipeline, agent { label 'docker' } sends the job to a matching agent. Testers use labels to send UI tests to agents with browsers or Docker installed, and to keep heavy test runs off the controller, which should only coordinate.
11

What are the advantages of version control for test code?

Save to ▾
Show answer
Git tracks changes, enables code review, branching and rollback and lets teams collaborate on the framework safely.
12

What is the use of Maven in automation projects?

Save to ▾
Show answer
It manages dependencies through pom.xml, builds the project, runs tests with Surefire and standardises structure across teams.
13

How do you integrate Selenium tests with Jenkins?

Save to ▾
Show answer
Create a job or pipeline that checks out code, runs mvn test, publishes reports and triggers on commits or schedules.
14

What is a Jenkins pipeline?

Save to ▾
Show answer
A scripted or declarative Jenkinsfile that defines stages such as build, test and deploy as code stored with the project.
15

What is the difference between git merge and git rebase?

Save to ▾
Show answer
Merge combines branches by creating a merge commit, keeping the full history exactly as it happened. Rebase replays your commits on top of another branch, producing a straight, linear history without a merge commit. Rebase is good for tidying a local feature branch before a pull request; never rebase commits that others have already pulled, because it rewrites history.
16

What is the Maven Surefire plugin and how do you configure it for TestNG?

Save to ▾
Show answer
Surefire runs tests during the test phase. For TestNG, configure suiteXmlFiles with the path to testng.xml, so mvn test runs that suite. You can pass system properties, set parallel and threadCount, and control reports. Make the suite file a property like ${suiteXml} so CI can choose smoke.xml or regression.xml with -DsuiteXml=smoke.xml.
17

What are Maven dependency scopes?

Save to ▾
Show answer
compile is the default and available everywhere. test is only for test compile and run, such as TestNG and REST Assured. provided is needed for compiling but supplied at runtime by the container. runtime is not needed to compile but needed to run, like JDBC drivers. system and import are rarer. In test projects, mark test libraries as test scope unless framework code in src/main uses them.
18

What are Maven profiles and how do you use them in automation?

Save to ▾
Show answer
Profiles are sets of configuration activated by name, such as -Pqa or -Pstaging, or by conditions. In automation they switch environment URLs, suite files, browsers or parallel settings without changing code. For example a regression profile sets suiteXml to regression.xml and threadCount to 4. Combined with properties files, profiles keep one codebase for every environment.
19

What is the difference between a declarative and a scripted Jenkins pipeline?

Save to ▾
Show answer
Declarative pipelines use a fixed structure: pipeline, agent, stages, steps, post, with built-in options and validation; they are easier to read and are the recommended default. Scripted pipelines use node blocks and full Groovy, giving more flexibility for complex logic but making them harder to maintain. Most test pipelines use declarative syntax with small script blocks only where needed.
20

Write a declarative Jenkinsfile that runs Maven tests and publishes results.

Save to ▾
Show answer
pipeline { agent any parameters { choice(name: 'SUITE', choices: ['smoke', 'regression']) } stages { stage('Checkout') { steps { checkout scm } } stage('Test') { steps { sh "mvn clean test -DsuiteXml=${params.SUITE}.xml" } } } post { always { junit 'target/surefire-reports/*.xml' archiveArtifacts artifacts: 'target/screenshots/**', allowEmptyArchive: true } } }
21

How do you store passwords and tokens safely in Jenkins?

Save to ▾
Show answer
Use the Jenkins Credentials store and bind them in the pipeline with withCredentials or the credentials() helper in environment blocks. Jenkins masks the values in console logs. Never hard-code secrets in the Jenkinsfile, pom.xml or properties files committed to Git. For larger setups, integrate a vault service and give each job only the credentials it needs.
22

Your Jenkins test stage marks the build green even though tests failed. Why?

Save to ▾
Show answer
Possibly testFailureIgnore is set to true in Surefire, the shell step uses || true, or the script swallows Maven's exit code. Sometimes tests catch exceptions and never fail. Check the console log for Maven's BUILD result and Surefire summary. Fix the configuration so failures produce a non-zero exit, or use junit publishing to mark the build unstable when tests fail.
23

What branching strategy do you use for test automation code?

Save to ▾
Show answer
Most teams use trunk-based development or a light GitHub Flow: short-lived feature branches from main, a pull request with review and a CI run, then merge. Long-lived branches cause painful conflicts. Keep automation code in the same repository as the app when possible so tests change together with features, or tag test versions to match app releases.
24

What is git cherry-pick?

Save to ▾
Show answer
git cherry-pick <commit> applies the changes of one specific commit onto your current branch, creating a new commit. It is useful when a fix on one branch, such as a locator fix on develop, is urgently needed on a release branch without merging everything else. Overuse creates duplicate commits and confusing history, so prefer normal merges when possible.
25

How do you undo a commit that has already been pushed?

Save to ▾
Show answer
Use git revert <commit>, which creates a new commit that reverses the changes and keeps history intact, safe for shared branches. git reset moves the branch pointer backwards and is fine for local commits, but resetting and force-pushing a shared branch rewrites history and breaks teammates' clones. If force push is truly needed, use --force-with-lease and tell the team.
26

Tell me about a time a CI pipeline you owned broke right before a release.

Save to ▾
Show answer
Situation: the night before release, every UI test failed in Jenkins. Task: find the cause fast and unblock the release. Action: I checked the console and saw a browser and driver version mismatch after an agent update, pinned the browser image version, reran the suite and shared a short note. Result: the release went out on time and we added image version pinning to the pipeline.
27

How do you publish Allure or Extent reports from Jenkins?

Save to ▾
Show answer
For Allure, install the Allure Jenkins plugin, configure the commandline tool, and add allure results: [[path: 'target/allure-results']] in the post always block. For Extent, archive the HTML file and use the HTML Publisher plugin to show it as a build link. Keep report history per build and share the link in failure notifications.
28

What is the difference between git reset --soft, --mixed and --hard?

Save to ▾
Show answer
All three move the current branch to another commit, but treat your changes differently. Soft keeps the changes staged, which is useful to squash recent commits. Mixed, the default, keeps the changes in the working folder but unstages them. Hard throws away staged and working changes completely, so use it carefully. Never reset commits that are already pushed to a shared branch; use git revert there instead.
29

What is the Maven Failsafe plugin and how is it different from Surefire?

Save to ▾
Show answer
Surefire runs unit tests in the test phase and stops the build as soon as tests fail. Failsafe runs integration tests in the integration-test phase and checks results later in the verify phase, so post-integration-test steps, like stopping a server or Docker containers, still run after failures. By default Failsafe picks classes named *IT. Many teams run UI and API suites through Failsafe with mvn verify for that reason.
30

Describe a time you automated a manual build or release step for the QA team.

Save to ▾
Show answer
Situation: before each regression a tester spent an hour deploying the build to QA and seeding data by hand. Task: remove that manual step. Action: I wrote a Jenkins pipeline stage that deployed the build, ran database seed scripts and a smoke check, then triggered the regression job, and documented it for the team. Result: setup dropped to ten minutes without human effort, and regressions could run overnight automatically.
31

How do you run tests on multiple browsers in parallel in Jenkins?

Save to ▾
Show answer
Use a parallel block in the pipeline with a stage per browser, or a matrix directive with axis BROWSER values chrome, firefox and edge. Each branch runs mvn test -Dbrowser=${BROWSER}, ideally against Selenium Grid or containers so agents do not need local browsers. Publish results per branch with clear names so failures show which browser broke.
32

What is a Maven multi-module project and when would you use it for automation?

Save to ▾
Show answer
A parent pom lists modules that share dependency versions through dependencyManagement and plugins through pluginManagement. In automation you might have core-framework, ui-tests, api-tests and performance modules. Teams can run or release modules separately, and shared code lives in one place. It is worth it when several teams or test types share the same framework.
33

How do you fix a Maven dependency conflict?

Save to ▾
Show answer
Run mvn dependency:tree to see which versions are pulled in transitively. Maven picks the nearest version, which may not be the one you need. Fix by declaring the required version in dependencyManagement, excluding the unwanted transitive dependency with exclusions, or upgrading the library that brings the old version. Conflicts often appear as NoSuchMethodError or ClassNotFoundException at runtime.
34

Nightly Jenkins regression runs take 4 hours. How would you bring it down?

Save to ▾
Show answer
Measure first: find the slowest tests and setup steps. Then run tests in parallel across Grid nodes or containers, replace UI setup with API calls, remove duplicate coverage, move checks down to API level, split the suite into shards across agents, and cache Maven dependencies. Aim for a smoke stage under 15 minutes on every commit and a parallel regression under an hour.

Frequently asked questions

How important is Git, Maven and Jenkins in Automation Testing interviews?

Covers the tooling around automation code: Git branching, merging, rebasing and conflict handling; Maven lifecycle, Surefire, profiles and dependencies; and Jenkins pipelines, triggers, credentials, parallel stages and reporting. Interviewers expect you to run your suite from the command line and in CI, not only from the IDE.

How should I use the Git, Maven and Jenkins sheet?

Go top to bottom — easy to hard. Answer before opening each answer, tick what you solved and save misses to Last-Minute Revision.