Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
You're offline
Unit 3 MCQsContinuous Integration (CI) & Build Automation
In a Jenkins declarative pipeline, what does the agent directive specify?
Not quite. Try another option.
Answer: Where the pipeline or stage will execute
The agent directive tells Jenkins which node or environment should run the pipeline or a particular stage.
Question 18 of 60 · Automated Builds · Easy
What is the main goal of an automated build?
Not quite. Try another option.
Answer: To compile and package code without manual steps
Automated builds compile source code, resolve dependencies, and produce artifacts automatically, reducing human error.
Question 19 of 60 · Automated Testing · Easy
Why is automated testing important in a CI pipeline?
Not quite. Try another option.
Answer: It quickly verifies code changes without manual effort
Automated tests run consistently and quickly on every change, giving fast feedback on whether code still works correctly.
Question 20 of 60 · Test Automation Basics (Unit Testing, Coverage) · Easy
What does code coverage measure?
Not quite. Try another option.
Answer: The percentage of code executed by tests
Code coverage indicates how much of the source code is exercised by automated tests, expressed as a percentage.
Question 21 of 60 · CI fundamentals and benefits · Medium
A team merges code into the shared main branch only once every two weeks, resulting in painful merge conflicts. Which core Continuous Integration principle would most directly address this problem?
Not quite. Try another option.
Answer: Integrating code changes frequently, ideally multiple times per day, into the shared mainline
CI's defining practice is frequent integration into the mainline. Small, frequent merges keep divergence low and drastically reduce the size and pain of merge conflicts.
Question 22 of 60 · CI fundamentals and benefits · Medium
Which outcome is the least likely direct benefit of adopting Continuous Integration?
Not quite. Try another option.
Answer: Automatic deployment of every commit to production users
Automatic deployment to production is Continuous Deployment, a separate practice. CI focuses on integrating and validating code, not releasing it to end users.
Question 23 of 60 · CI Pipeline Architecture · Medium
In a typical CI pipeline, what event most commonly acts as the trigger that starts a pipeline run?
Not quite. Try another option.
Answer: A push or pull request to the version control repository
CI pipelines are event-driven and are most commonly triggered by commits/pushes or pull requests, so code is validated as soon as it changes.
Question 24 of 60 · CI Pipeline Architecture · Medium
A pipeline is arranged so that if the compile/build stage fails, no later stages run. What is the primary reason for this fail-fast ordering?
Not quite. Try another option.
Answer: Running tests on code that does not compile wastes resources and gives no useful signal
Fail-fast pipelines stop early when a foundational stage fails. There is no point testing artifacts that never built, so stopping saves time and compute.
Question 25 of 60 · Popular CI Tools: Jenkins, GitHub Actions, GitLab CI, CircleCI · Medium
Which statement correctly distinguishes GitHub Actions from a self-hosted Jenkins server in a default setup?
Not quite. Try another option.
Answer: GitHub Actions runs on cloud-hosted runners managed by GitHub, while Jenkins is typically installed and maintained on your own infrastructure
GitHub Actions offers managed cloud runners out of the box, while Jenkins is traditionally self-hosted. Note Jenkins uses Groovy pipelines and Actions uses YAML—the reverse of one distractor.
Question 26 of 60 · Popular CI Tools: Jenkins, GitHub Actions, GitLab CI, CircleCI · Medium
In GitLab CI, which file located at the repository root defines the pipeline configuration?
Not quite. Try another option.
Answer: .gitlab-ci.yml
GitLab CI reads its pipeline definition from .gitlab-ci.yml. The others belong to Jenkins, older CircleCI, and GitHub Actions respectively.
Question 27 of 60 · Popular CI Tools: Jenkins, GitHub Actions, GitLab CI, CircleCI · Medium
A team wants to run each job of their CI pipeline inside a fresh, isolated container image they specify. Which CI tool is especially known for making per-job Docker containers a first-class, native concept via a docker executor?
Not quite. Try another option.
Answer: CircleCI
CircleCI natively supports specifying a Docker image executor per job, running each job in an isolated container. Make and Ant are build tools, not CI orchestrators.
Question 28 of 60 · Build Tools Overview: Maven, Gradle, npm · Medium
A Java project uses Maven. Which command compiles the code, runs tests, and packages the result into a JAR/WAR without installing it to the local repository?
Not quite. Try another option.
Answer: mvn package
mvn package runs through compile and test and produces the packaged artifact in target/. install also copies it to the local repo, and deploy pushes to a remote repo.
Question 29 of 60 · Build Tools Overview: Maven, Gradle, npm · Medium
What is the primary functional advantage of Gradle's incremental build support compared to a naive full rebuild every time?
Not quite. Try another option.
Answer: It re-executes only the tasks whose inputs or outputs have changed, reducing build time
Gradle tracks task inputs and outputs and skips up-to-date tasks, so only affected work is re-run. This incremental behavior significantly speeds up repeated builds.
Question 30 of 60 · Build Tools Overview: Maven, Gradle, npm · Medium
In a Node.js project, which file records the exact resolved version of every installed dependency to ensure reproducible installs across machines?
Not quite. Try another option.
Answer: package-lock.json
package.json declares version ranges, but package-lock.json pins the exact resolved versions of the full dependency tree, making installs reproducible.
Question 31 of 60 · Build Tools Overview: Maven, Gradle, npm · Medium
Which pair correctly matches a build tool with the ecosystem it is most commonly used in?
Not quite. Try another option.
Answer: Maven — Java; npm — JavaScript/Node.js
Maven is a Java build/dependency tool, while npm is the package manager for the JavaScript/Node.js ecosystem. The other pairings mismatch the tools and ecosystems.
Question 32 of 60 · Writing Jenkins Declarative Pipelines · Medium
In a Jenkins Declarative Pipeline, which block is required at the top level to specify where the pipeline will execute?
Not quite. Try another option.
Answer: agent
A Declarative Pipeline must include an agent directive at the top level, defining where (which node/executor) the pipeline or stage runs.
Question 33 of 60 · Writing Jenkins Declarative Pipelines · Medium
Consider this Jenkins snippet:
groovy
post {
always {
echo 'Cleaning up'
}
}
When does the always block execute?
Not quite. Try another option.
Answer: After the stages complete, regardless of whether the build succeeded or failed
In the post section, the always condition runs after the pipeline finishes no matter the result—useful for cleanup and notifications.
Question 34 of 60 · Writing Jenkins Declarative Pipelines · Medium
In a Declarative Pipeline, where must individual stage blocks be placed?
Not quite. Try another option.
Answer: Inside a stages block
Declarative Pipelines group all stage definitions inside a single stages block, which holds the ordered sequence of work.
Question 35 of 60 · Writing Jenkins Declarative Pipelines · Medium
A pipeline author wants a variable available as an environment variable to every step in all stages of the build. Which directive should be used at the top level of the Declarative Pipeline?
Not quite. Try another option.
Answer: environment
A top-level environment block defines environment variables that apply to all stages and their steps. Placed inside a stage, it would be scoped to that stage only.
Question 36 of 60 · Automated Builds · Medium
Which practice best characterizes an automated build in a CI context?
Not quite. Try another option.
Answer: A single command or trigger compiles the code, resolves dependencies, and produces artifacts without manual steps
Automated builds are reproducible and hands-off: one trigger performs compilation, dependency resolution, and artifact creation, eliminating manual, error-prone steps.
Question 37 of 60 · Automated Builds · Medium
Why is producing a versioned, immutable build artifact (e.g., a specific JAR) important in a CI/CD workflow?
Not quite. Try another option.
Answer: The same tested artifact can be promoted through environments, ensuring what was tested is what gets deployed
Build-once, deploy-many relies on immutable artifacts. Promoting the identical artifact through environments guarantees the deployed build matches the tested build.
Question 38 of 60 · Automated Testing · Medium
A CI pipeline runs unit tests automatically on every push. A commit introduces code that breaks a test. What is the most valuable immediate benefit of this automation?
Not quite. Try another option.
Answer: The regression is detected right after the commit that caused it, making it easy to locate and fix
Automated testing on each push gives fast feedback, tying a failure to the specific change that caused it, which greatly simplifies debugging.
Question 39 of 60 · Automated Testing · Medium
Which ordering of test types generally reflects a healthy test pyramid, from most to fewest tests?
Not quite. Try another option.
Answer: Unit tests → integration tests → end-to-end tests
The test pyramid favors many fast, cheap unit tests at the base, fewer integration tests in the middle, and the fewest slow end-to-end tests at the top.
Question 40 of 60 · Test Automation Basics (Unit Testing, Coverage) · Medium
A test suite reports 85% line coverage. What does this figure specifically indicate?
Not quite. Try another option.
Answer: 85% of the executable lines of code were run at least once during the tests
Line coverage measures the proportion of executable lines executed during testing. High coverage does not by itself prove correctness or absence of bugs.
Question 41 of 60 · CI fundamentals and benefits · Hard
A team practices trunk-based development with CI, but developers still experience frequent 'integration hell' at release time. Investigation shows that although commits are pushed to the main branch several times daily, the CI pipeline only runs a compile step and no tests, and feature flags are absent. Which corrective action most directly restores the core CI benefit being violated?
Not quite. Try another option.
Answer: Add automated test execution to every pipeline run so integration defects surface at commit time
CI's core value is early detection of integration problems through automated verification. Frequent commits without automated tests provide no feedback on correctness, so defects accumulate until release. Adding automated tests to each run restores the fast-feedback benefit.
Question 42 of 60 · CI Pipeline Architecture · Hard
In a fan-out/fan-in CI pipeline, a build stage produces an artifact consumed by three parallel test stages (unit, integration, contract), which then converge into a single deploy stage. If the integration test stage has a flaky 20% failure rate per run and the pipeline retries only that stage up to 2 additional times, what is the approximate probability the pipeline reaches the deploy stage on a given trigger (assuming other stages always pass)?
Not quite. Try another option.
Answer:
The stage fails only if all attempts fail. With 3 total attempts at 20% failure each, , so success . The fan-in deploy requires this stage to eventually pass.
Question 43 of 60 · Writing Jenkins Declarative Pipelines · Hard
The Test stage fails because target/app.bin does not exist. What is the root cause?
Not quite. Try another option.
Answer: Each stage's agent runs in a separate workspace, so build artifacts are not automatically shared unless stashed/archived
With agent none and per-stage agents, stages may run on different executors/workspaces. Files from Build are not visible to Test unless passed via stash/unstash or archiveArtifacts. This is a common cross-agent workspace pitfall.
Question 44 of 60 · Build Tools Overview: Maven, Gradle, npm · Hard
A Gradle build is slow on CI despite the code changing minimally between runs. The CI runner is ephemeral (fresh container per build). Which combination most effectively reduces build time while remaining correct?
Not quite. Try another option.
Answer: Enable the Gradle build cache with a shared remote cache and persist the Gradle user home across runs
Ephemeral runners lose Gradle's local incremental state each build. A shared remote build cache lets task outputs be reused across ephemeral machines, and persisting the Gradle user home preserves dependency downloads—both dramatically cut time without sacrificing correctness.
Question 45 of 60 · Test Automation Basics (Unit Testing, Coverage) · Hard
A module has 100% line coverage but a production bug slips through: a function divide(a, b) throws on b == 0, which callers never handle. Why did high coverage fail to catch this, and what metric would have exposed the gap?
Not quite. Try another option.
Answer: Line coverage does not measure untested input partitions or branches; branch/path coverage on the divisor would expose the missing case
Line coverage only confirms a line executed, not that all input equivalence classes or branches were exercised. The edge case was never tested. Branch/path coverage combined with boundary-value analysis would flag the unexecuted error path.
Question 46 of 60 · Popular CI Tools: Jenkins, GitHub Actions, GitLab CI, CircleCI · Hard
In GitHub Actions, a workflow defines two jobs: build and deploy, where deploy has needs: build. Both jobs set concurrency: production. A developer pushes two commits in quick succession. What behavior results?
Not quite. Try another option.
Answer: The second run's jobs sharing the production concurrency group cancel or queue against the first, since concurrency groups are evaluated per matching key across runs
A concurrency group serializes across workflow runs: only one job/run per group key proceeds at a time; others queue or are cancelled (with cancel-in-progress). This prevents overlapping production deploys from concurrent pushes.
Question 47 of 60 · Automated Builds · Hard
A reproducible build requirement states that building the same commit twice must yield byte-identical artifacts. A Java build currently fails this check. Which factor is the most likely culprit?
Not quite. Try another option.
Answer: Embedded build timestamps and non-deterministic file ordering inside the JAR manifest/zip entries
Reproducible builds are commonly broken by embedded timestamps and unstable entry ordering in archives. Fixes include setting a fixed timestamp (e.g., SOURCE_DATE_EPOCH) and sorting zip entries. Locked dependencies and consistent JDKs actually aid reproducibility.
Question 48 of 60 · CI Pipeline Architecture · Hard
A pipeline uses caching to speed up dependency installation. After a security advisory, a compromised dependency version was published and later yanked. The team pins versions but still gets the compromised artifact on some CI runs. What architectural flaw explains this?
Not quite. Try another option.
Answer: The cache key does not incorporate the lockfile hash, so stale cached dependencies persist despite pin changes
If the cache key isn't derived from the lockfile/manifest hash, changing pins won't invalidate the cache, so old (compromised) artifacts get restored. Keying the cache on the lockfile hash ensures dependency changes force a cache miss and fresh fetch.
Question 49 of 60 · Writing Jenkins Declarative Pipelines · Hard
In a Jenkins declarative pipeline, you need a stage to run only when the branch is main AND a prior stage set an environment variable DEPLOYABLE=true. Which when construct is correct?
allOf requires every nested condition to be true (logical AND). The branch and environment conditions are valid declarative when directives. anyOf is OR, and the other forms use invalid syntax.
Question 50 of 60 · Automated Testing · Hard
A CI suite runs 5000 tests in 40 minutes. The team wants sub-10-minute feedback. They shard tests across 4 parallel runners by simple alphabetical file split, but one runner consistently takes 30 minutes. What is the best fix?
Not quite. Try another option.
Answer: Split shards using historical per-test timing data so each runner gets balanced execution time
Alphabetical splits ignore per-test duration, causing skew when slow tests cluster. Timing-based (test-splitting by recorded durations) balances wall-clock time across shards, achieving near-optimal parallel speedup. Just adding runners won't fix the imbalance.
Question 51 of 60 · Build Tools Overview: Maven, Gradle, npm · Hard
During npm ci on CI, the build fails with an error that package-lock.json is out of sync with package.json. A developer suggests switching to npm install to 'auto-fix' it. Why is this the wrong fix for CI?
Not quite. Try another option.
Answer: npm install may mutate the lockfile and install differing versions, breaking reproducibility; the lockfile should be regenerated and committed locally instead
npm ci requires the lockfile and package.json to be in sync and installs exactly what's locked—ideal for CI reproducibility. npm install can silently update the lockfile and resolve different versions. The correct fix is to reconcile and commit the lockfile locally.
Question 52 of 60 · Popular CI Tools: Jenkins, GitHub Actions, GitLab CI, CircleCI · Hard
In GitLab CI, a job in the test stage must run only for merge requests targeting main, but never on scheduled pipelines. Which rules configuration achieves this correctly?
The first rule matches MR pipelines targeting main. A separate rule with when: never for scheduled pipelines guarantees exclusion. GitLab evaluates rules top-down; the explicit never guard on schedules is the reliable pattern.
Question 53 of 60 · Test Automation Basics (Unit Testing, Coverage) · Hard
A team enforces a coverage gate of 80%. A developer adds a large auto-generated file with no tests, dropping coverage below the gate. To pass, they add coverage exclusions for generated code. Later, a genuine untested handler also gets excluded by an overly broad glob. What is the key lesson about coverage gates?
Not quite. Try another option.
Answer: Coverage exclusions must be narrowly scoped; broad globs can mask real untested code and give false confidence
Excluding generated code is legitimate, but overly broad exclusion patterns can silently drop real production code from measurement, defeating the gate's purpose. Exclusions should be precise and reviewed to avoid hiding genuine coverage gaps.
Question 54 of 60 · CI fundamentals and benefits · Hard
A manager claims 'we have CI because we run a nightly build and test job'. A CI expert disagrees. Which argument best explains why a nightly-only build is not true Continuous Integration?
Not quite. Try another option.
Answer: CI requires integration and verification on every commit/merge to give fast feedback; nightly batching delays defect detection and reintroduces integration risk
The defining property of CI is that each integration (commit/merge) triggers an automated build and test, so defects are caught within minutes. Nightly batching accumulates a day's changes before feedback, undermining the fast-feedback and low-integration-risk benefits.
Question 55 of 60 · Automated Builds · Hard
A Maven multi-module project builds fine locally but fails on CI with 'Could not resolve dependencies for project A: artifact B not found'. Module A depends on module B, both in the same reactor. Locally, B was previously mvn installed. What is the correct CI-safe build command?
Not quite. Try another option.
Answer: Build the whole reactor together, e.g. mvn -pl A -am install, so B is built before A in the same run
The local build worked because B was already installed in ~/.m2. Fresh CI has no such cache. -pl A -am (also-make) builds A plus its required upstream modules (B) in one reactor run, resolving the intra-project dependency correctly.
Question 56 of 60 · Popular CI Tools: Jenkins, GitHub Actions, GitLab CI, CircleCI · Hard
In CircleCI, a workflow uses a context to inject shared secrets and restricts it to a security group. A contractor's job in the same workflow needs a different, non-privileged credential set. What is the correct approach to enforce least privilege?
Not quite. Try another option.
Answer: Assign each job its own context so secrets are scoped per job, granting the contractor's job only the non-privileged context
CircleCI contexts scope secrets and can be restricted by security groups. Per-job context assignment enforces least privilege: the contractor's job receives only its designated non-privileged context, while privileged contexts remain inaccessible to it.
Question 57 of 60 · Writing Jenkins Declarative Pipelines · Hard
A declarative pipeline must guarantee that a cleanup step runs whether the build succeeds, fails, or is aborted, and a notification runs only on failure. Which structure is correct?
Not quite. Try another option.
Answer: Use post { always { cleanup } failure { notify } } at the pipeline or stage level
The declarative post section provides condition blocks: always runs regardless of result (ideal for cleanup), while failure runs only when the build fails (ideal for alerts). Declarative pipelines don't allow raw try/finally at the top level.
Question 58 of 60 · Automated Testing · Hard
A CI pipeline reports intermittent test failures that disappear on re-run. Analysis shows two tests share a database table and run in parallel. Which statement best characterizes the problem and the most robust fix?
Not quite. Try another option.
Answer: The tests are not isolated (shared mutable state); isolate them via per-test transactions/schemas or unique data, rather than relying on retries
Shared mutable state (the common table) creates order-dependent interference under parallelism—a classic test isolation defect. The robust fix is true isolation (transaction rollback, per-test schema, or unique keys), not masking with retries or sleeps.
Question 59 of 60 · CI Pipeline Architecture · Hard
A pipeline separates a fast 'commit stage' (compile + unit tests, target < 5 min) from a slower 'acceptance stage'. A proposal suggests moving slow end-to-end tests into the commit stage 'to catch more bugs earlier'. Why does this typically harm the pipeline?
Not quite. Try another option.
Answer: It inflates commit-stage duration, destroying the fast-feedback contract and increasing the cost of every commit's verification
The commit stage exists to give rapid feedback (minutes). Loading slow, broad e2e tests into it breaks that contract and slows every developer's cycle. Staged pipelines intentionally keep slow tests later so fast checks fail fast.
Question 60 of 60 · Build Tools Overview: Maven, Gradle, npm · Hard
Comparing Maven and Gradle for a large monorepo, a team values incremental builds and task-level caching but also wants a low-magic, declarative configuration. Which trade-off statement is most accurate?
Not quite. Try another option.
Answer: Gradle offers superior incremental/cacheable task graphs but its Groovy/Kotlin DSL is imperative and can grow complex, while Maven's XML is more declarative but less flexible for fine-grained incrementality
Gradle's task-graph model enables fine-grained incremental builds and build caching, but its scripting DSL is programmatic and can become hard to reason about. Maven's XML lifecycle is more declarative and predictable but offers coarser incrementality. This captures the real trade-off.
That's unit 3
Answer a few questions and your score shows up here.
Nearly through. Did unit 3 of INT331 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 3 of INT331 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.