92 lines
5.0 KiB
Markdown
92 lines
5.0 KiB
Markdown
# Jenkins tests and JaCoCo coverage
|
|
|
|
Configure a Jenkins Pipeline from SCM using this repository and the Script Path
|
|
`files/config/Jenkinsfile`. The pipeline follows the Prometeu Studio reference,
|
|
adapted to AIE's single Gradle project and Java 25 target.
|
|
|
|
Use a Unix agent with Git, JDK 25 and dependency/cache access. No GraalVM compiler,
|
|
native executable, sibling project, model CLI or model credentials are required.
|
|
The checked-in Gradle Wrapper selects Gradle 9.3.1; no named Jenkins Gradle tool
|
|
installation is needed. `GRADLE_USER_HOME` defaults to `/var/jenkins_home/.gradle`,
|
|
matching Studio; adjust it if the chosen agent uses another writable cache path.
|
|
The AIE CLI has no display requirement. Unlike Studio, this pipeline does not add
|
|
global `JAVA_TOOL_OPTIONS`: the JVM prints that variable to stderr and would pollute
|
|
the CLI output captured by the separate-process continuity tests.
|
|
|
|
The controller needs Declarative Pipeline, Gradle (`withGradle`), JUnit, Checks API
|
|
(`withChecks`), Coverage (`recordCoverage`) and HTML Publisher plugins. An appropriate
|
|
SCM checks provider is needed to publish commit checks. These are the same report
|
|
steps used by Studio; this repository does not install or configure controller plugins.
|
|
|
|
## Commands and reports
|
|
|
|
```sh
|
|
./gradlew clean --no-daemon --console=plain
|
|
./gradlew test jacocoTestReport jenkinsPipelineTest --continue --parallel --max-workers=2 --build-cache --no-daemon --console=plain
|
|
```
|
|
|
|
Clean runs separately so a preparation failure cannot publish stale reports as a
|
|
new test run. `--continue` retains a failing exit code while allowing independent
|
|
verification to finish. `test` finalizes with `jacocoTestReport`; invoking the report
|
|
task directly consumes existing execution data. CI schedules both tasks explicitly;
|
|
the report has an ordering constraint rather than a dependency on test success,
|
|
so a failed test cannot suppress available coverage. JaCoCo 0.8.14 is pinned for Java 25 support.
|
|
The report includes the main Java source set without coverage-driven exclusions.
|
|
|
|
| Output | Workspace-relative location |
|
|
|---|---|
|
|
| JUnit XML | `build/test-results/test/TEST-*.xml` |
|
|
| Test HTML | `build/reports/tests/test/index.html` |
|
|
| JaCoCo XML | `build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml` |
|
|
| Coverage HTML | `build/reports/jacoco/jacocoTestReport/html/index.html` |
|
|
| Raw JaCoCo data | `build/jacoco/test.exec` |
|
|
|
|
JUnit completes the check `Test / Tests and coverage`; the separate coverage check
|
|
is `JaCoCo Coverage`. Configure required SCM check names to match these values.
|
|
Coverage gates match Studio: CLASS, METHOD, LINE and INSTRUCTION at 50%, BRANCH at
|
|
40%, baseline PROJECT, criticality UNSTABLE. A missed coverage gate makes the Jenkins
|
|
build unstable; it does not convert a failed test run into a successful build.
|
|
No extra local `jacocoTestCoverageVerification` threshold is imposed.
|
|
|
|
## Failure reporting
|
|
|
|
After verification starts, the unconditional post block attempts JUnit, Coverage,
|
|
HTML and raw artifact publication independently. An exception in one publisher
|
|
does not suppress the others. Coverage processing errors fail publication and
|
|
coverage is enabled for failed builds. The archive retains test XML/binary output,
|
|
test HTML, coverage XML/HTML and raw `.exec` data on failed and unstable builds too.
|
|
Retention follows the Jenkins job's build/artifact policy.
|
|
|
|
Successful verification must produce nonempty JUnit results, coverage XML and HTML.
|
|
Missing successful-build evidence fails publication. Compilation or setup failure
|
|
may leave no reports; available diagnostics are retained and the original build
|
|
failure remains authoritative. A failed clean attempts no publishers.
|
|
|
|
## Local validation and limits
|
|
|
|
```sh
|
|
./gradlew jenkinsPipelineTest --console=plain
|
|
```
|
|
|
|
This task executes the actual Jenkinsfile with controlled Pipeline steps, using
|
|
Gradle's bundled Groovy without a new application/test dependency. Eleven cases
|
|
exercise success, failed clean with stale paths, failed verification with partial
|
|
reports, no reports, missing successful-build reports and isolated publisher errors.
|
|
The task is also part of `check` and is invoked explicitly by this pipeline.
|
|
|
|
JUnit/JaCoCo reports come from the JVM `test` task. Separate CLI subprocesses and
|
|
native smoke tests are not instrumented by the worker's JaCoCo agent; the report
|
|
does not claim native or external-provider coverage. Tests use deterministic
|
|
fixtures and require no real model calls.
|
|
|
|
The local Pipeline fixture is not a Jenkins controller or a plugin implementation.
|
|
It cannot certify plugin compatibility, actual SCM checks or UI publication. A run
|
|
of the configured Jenkins job is required to verify those integration details.
|
|
Existing GitHub Actions native builds remain a separate workflow.
|
|
|
|
References: [Gradle JaCoCo plugin](https://docs.gradle.org/current/userguide/jacoco_plugin.html),
|
|
[JaCoCo 0.8.14 / Java 25](https://github.com/jacoco/jacoco/releases/tag/v0.8.14),
|
|
[JUnit](https://www.jenkins.io/doc/pipeline/steps/junit/),
|
|
[Coverage](https://www.jenkins.io/doc/pipeline/steps/coverage/) and
|
|
[HTML Publisher](https://www.jenkins.io/doc/pipeline/steps/htmlpublisher/).
|