Let us create your first Jenkins job. We will start with a Freestyle job — it is GUI-based, no code needed. Think of it as training wheels. You will switch to Pipeline jobs later, but Freestyle teaches you the core concepts.
Click "Build Now" on the left sidebar. Jenkins starts the job. Click the build number (#1) and then "Console Output" to watch it live. You will see Maven downloading dependencies, compiling code, and running tests. First build takes 5-10 minutes because of dependency downloads. Later builds are faster.
mvn clean test -DsuiteXmlFile=testng.xml -Dheadless=true
# Breakdown:
# clean — Delete old compiled files (target/ folder)
# test — Compile code + run tests
# -D — Pass a system property to Maven/TestNG
# suiteXmlFile — Which testng.xml to use
# headless — Tell your BaseTest to run Chrome without a windowIf the build fails with "mvn: command not found," you forgot to configure Maven in Manage Jenkins > Tools. If it fails with "JAVA_HOME not set," configure JDK in the same place.
| Color | Meaning | Action |
|---|---|---|
| Blue (sun) | All tests passed | Nothing — life is good |
| Yellow (clouds) | Unstable — some tests failed | Check test report, fix flaky tests |
| Red (storm) | Build failed — compilation error or crash | Check console output immediately |
| Gray | Aborted or never built | Check if job was cancelled |
Freestyle jobs are NOT stored in your Git repo. If you delete the job or Jenkins crashes without a backup, the entire configuration is gone. This is why real teams use Pipeline jobs. Freestyle is for learning only.
Q: How do you create a Jenkins job to run Selenium tests?
A: There are two approaches. For quick setups, I create a Freestyle job — configure Git repo URL, set Maven build step with "clean test -DsuiteXmlFile=testng.xml -Dheadless=true", and add TestNG post-build report action. For real projects, I use a Pipeline job with a Jenkinsfile stored in the repo. The Jenkinsfile has stages for checkout, build, test execution in headless mode, Allure report generation, and email notification on failure. Pipeline is better because it is version-controlled and code-reviewed.
Key Point: Freestyle jobs are configured via GUI. Use "mvn clean test" as the build step. Freestyle is for learning — Pipeline is for real projects.