0
0
Jenkinsdevops~20 mins

Build tools (Maven, Gradle, npm) in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Build Tools Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Maven build command?
You run the following command in a Jenkins pipeline:
mvn clean install -DskipTests

What will be the main effect of this command?
Jenkins
mvn clean install -DskipTests
AIt cleans the project, compiles the code, packages it, and skips running tests.
BIt only runs the tests without building the project.
CIt installs dependencies but does not compile or package the project.
DIt cleans the project and runs tests but does not package the code.
Attempts:
2 left
💡 Hint
The 'clean' phase removes previous build files, 'install' compiles and packages, and '-DskipTests' skips tests.
Configuration
intermediate
2:00remaining
Which Gradle build script snippet correctly applies the Java plugin and sets the Java version to 17?
Choose the correct Gradle build script snippet to apply the Java plugin and set the Java source and target compatibility to version 17.
A
plugins {
    id 'java'
}

java {
    sourceCompatibility = '17'
    targetCompatibility = '17'
}
B
plugins {
    id 'java'
}

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}
C
apply plugin: 'java'

sourceCompatibility = '1.7'
targetCompatibility = '1.7'
D
apply plugin: 'java'

java {
    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7
}
Attempts:
2 left
💡 Hint
Use JavaVersion constants for version 17 and the plugins block for modern Gradle scripts.
🔀 Workflow
advanced
2:00remaining
In a Jenkins pipeline, which npm command sequence correctly installs dependencies and runs tests with coverage?
You want to install npm dependencies and then run tests with coverage reporting in a Jenkins pipeline. Which command sequence is correct?
Anpm install && npm run test:coverage
Bnpm run test:coverage && npm install
Cnpm test && npm install
Dnpm install test:coverage
Attempts:
2 left
💡 Hint
Dependencies must be installed before running tests.
Troubleshoot
advanced
2:00remaining
What error will this Maven command produce if the pom.xml file is missing?
You run this command in a Jenkins job:
mvn clean package

But the pom.xml file is missing in the workspace. What error will Maven show?
Jenkins
mvn clean package
A[ERROR] Could not find the 'package' command.
B[ERROR] Missing Java compiler version in pom.xml.
C[ERROR] The goal you specified requires a project to execute but there is no POM in this directory.
D[ERROR] Network connection failed while downloading dependencies.
Attempts:
2 left
💡 Hint
Maven requires a pom.xml file to run goals like clean or package.
Best Practice
expert
2:00remaining
Which npm script configuration in package.json ensures tests run only after dependencies are installed in Jenkins?
You want to configure your package.json scripts so that running npm run ci-test in Jenkins installs dependencies and then runs tests. Which scripts section is correct?
Jenkins
{
  "scripts": {
    "install": "npm install",
    "test": "jest",
    "ci-test": "???"
  }
}
A"ci-test": "npm test"
B"ci-test": "npm test && npm install"
C"ci-test": "npm install; npm test"
D"ci-test": "npm install && npm test"
Attempts:
2 left
💡 Hint
Tests should run after dependencies are installed; use && to chain commands.