Skip to content

Commit

Permalink
Migrate from EE 8 to EE 9
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Feb 12, 2025
1 parent 4ed1765 commit 714c09d
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 49 deletions.
4 changes: 1 addition & 3 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-pom</artifactId>
<version>8.6.0</version>
<version>10.2.0</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -34,7 +34,6 @@
<!-- Test Library Dependencies Versions -->
<xmlunit.version>2.10.0</xmlunit.version>
<testcontainers.version>1.20.4</testcontainers.version>
<job-dsl.version>1.87</job-dsl.version>

<arcmutate.git.version>2.0.0</arcmutate.git.version>
</properties>
Expand Down Expand Up @@ -299,7 +298,6 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>job-dsl</artifactId>
<version>${job-dsl.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
/**
* A pipeline {@code Step} or Freestyle or Maven {@link Recorder} that reads and parses coverage results in a build and
* adds the results to the persisted build results.
*
* <p>
* Stores the created issues in a {@link Node}. This result is then attached to the {@link Run build} by registering a
* {@link CoverageBuildAction}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import edu.hm.hafner.util.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.StaplerResponse2;
import org.kohsuke.stapler.bind.JavaScriptMethod;
import hudson.model.Api;
import hudson.model.ModelObject;
Expand Down Expand Up @@ -471,7 +471,7 @@ public boolean isSourceFileAvailable(final FileNode coverageNode) {
*/
@SuppressWarnings("unused") // Called by jelly view
@CheckForNull
public Object getDynamic(final String link, final StaplerRequest request, final StaplerResponse response) {
public Object getDynamic(final String link, final StaplerRequest2 request, final StaplerResponse2 response) {
if (MODIFIED_LINES_API_URL.equals(link)) {
return new ModifiedLinesCoverageApiModel(node);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import hudson.model.Descriptor;
import hudson.model.FreeStyleProject;

import io.jenkins.plugins.coverage.metrics.steps.CoverageRecorder;
Expand Down Expand Up @@ -58,7 +59,7 @@ void addCoverageRecorder(final FreeStyleProject project,
project.getPublishersList().add(recorder);
}

protected WorkflowJob createPipeline(final Parser parser, final String... fileNames) {
protected WorkflowJob createPipeline(final Parser parser, final String... fileNames) throws Descriptor.FormException {
WorkflowJob job = createPipelineWithWorkspaceFiles(fileNames);

setPipelineScript(job,
Expand All @@ -67,14 +68,14 @@ protected WorkflowJob createPipeline(final Parser parser, final String... fileNa
return job;
}

protected void setPipelineScript(final WorkflowJob job, final String recorderSnippet) {
protected void setPipelineScript(final WorkflowJob job, final String recorderSnippet) throws Descriptor.FormException {
job.setDefinition(new CpsFlowDefinition(
"node {\n"
+ recorderSnippet + "\n"
+ " }\n", true));
}

protected WorkflowJob createDeclarativePipeline(final Parser parser, final String... fileNames) {
protected WorkflowJob createDeclarativePipeline(final Parser parser, final String... fileNames) throws Descriptor.FormException {
WorkflowJob job = createPipelineWithWorkspaceFiles(fileNames);

job.setDefinition(new CpsFlowDefinition("pipeline {\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import hudson.model.Descriptor;
import hudson.model.Run;

import io.jenkins.plugins.coverage.metrics.AbstractCoverageITest;
Expand Down Expand Up @@ -54,18 +55,18 @@ abstract class SourceCodeITest extends AbstractCoverageITest {

@ParameterizedTest(name = "Entries of `sourceDirectories` use absolute paths: {0}")
@ValueSource(booleans = {true, false})
void verifySourcesInWorkspaceRoot(final boolean useAbsolutePath) throws IOException {
void verifySourcesInWorkspaceRoot(final boolean useAbsolutePath) throws Exception {
runCoverageWithSourceCode("", useAbsolutePath);
}

@ParameterizedTest(name = "Entries of `sourceDirectories` use absolute paths: {0}")
@ValueSource(booleans = {true, false})
void verifySourcesInWorkspaceSubFolder(final boolean useAbsolutePath) throws IOException {
void verifySourcesInWorkspaceSubFolder(final boolean useAbsolutePath) throws Exception {
runCoverageWithSourceCode("sub-dir", useAbsolutePath);
}

@Test
void verifySourcesInApprovedExternalFolder() throws IOException {
void verifySourcesInApprovedExternalFolder() throws Exception {
String directory = createExternalFolder();
PrismConfiguration.getInstance().setSourceDirectories(List.of(new PermittedSourceCodeDirectory(directory)));

Expand All @@ -75,7 +76,7 @@ void verifySourcesInApprovedExternalFolder() throws IOException {
}

@Test
void refuseSourceCodePaintingInNotApprovedExternalFolder() throws IOException {
void refuseSourceCodePaintingInNotApprovedExternalFolder() throws Exception {
PrismConfiguration.getInstance().setSourceDirectories(List.of());

var localAgent = crateCoverageAgent();
Expand All @@ -101,7 +102,7 @@ void refuseSourceCodePaintingInNotApprovedExternalFolder() throws IOException {
}

private Run<?, ?> runCoverageWithSourceCode(final String sourceDir, final boolean useAbsolutePath)
throws IOException {
throws Exception {
var localAgent = crateCoverageAgent();

WorkflowJob job = createPipeline();
Expand Down Expand Up @@ -157,7 +158,7 @@ private void copyReports(final hudson.model.Node localAgent, final WorkflowJob j
}

private CpsFlowDefinition createPipelineWithSourceCode(final SourceCodeRetention sourceCodeRetention,
final String sourceDirectory) {
final String sourceDirectory) throws Descriptor.FormException {
return new CpsFlowDefinition("node ('coverage-agent') {"
+ " recordCoverage "
+ " tools: [[parser: 'JACOCO', pattern: '" + ACU_COBOL_PARSER_COVERAGE_REPORT + "']], \n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void shouldFailWithoutParserInFreestyleJob() {
}

@Test
void shouldFailWithoutParserInPipeline() {
void shouldFailWithoutParserInPipeline() throws Exception {
WorkflowJob job = createPipeline();

setPipelineScript(job, "recordCoverage()");
Expand All @@ -88,7 +88,7 @@ void shouldReportErrorWhenNoFilesHaveBeenFoundInFreestyleJob(final Parser parser
@EnumSource
@ParameterizedTest(name = "{index} => Pipeline with parser {0}")
@DisplayName("Report error but do not fail build in pipeline when no input files are found")
void shouldReportErrorWhenNoFilesHaveBeenFoundInPipeline(final Parser parser) {
void shouldReportErrorWhenNoFilesHaveBeenFoundInPipeline(final Parser parser) throws Exception {
WorkflowJob job = createPipeline(parser);

verifyLogMessageThatNoFilesFound(job);
Expand All @@ -113,7 +113,7 @@ void shouldFailBuildWhenNoFilesHaveBeenFoundInFreestyleJob(final Parser parser)
@EnumSource
@ParameterizedTest(name = "{index} => Pipeline with parser {0}")
@DisplayName("Report error and fail build in pipeline when no input files are found")
void shouldFailBuildWhenNoFilesHaveBeenFoundInPipeline(final Parser parser) {
void shouldFailBuildWhenNoFilesHaveBeenFoundInPipeline(final Parser parser) throws Exception {
WorkflowJob job = createPipeline();

setPipelineScript(job,
Expand All @@ -138,14 +138,14 @@ void shouldRecordOneJacocoResultInFreestyleJob() {
}

@Test
void shouldRecordOneJacocoResultInPipeline() {
void shouldRecordOneJacocoResultInPipeline() throws Exception {
WorkflowJob job = createPipeline(Parser.JACOCO, JACOCO_ANALYSIS_MODEL_FILE);

verifyOneJacocoResult(job);
}

@Test
void shouldRecordOneJacocoResultInDeclarativePipeline() {
void shouldRecordOneJacocoResultInDeclarativePipeline() throws Exception {
WorkflowJob job = createDeclarativePipeline(Parser.JACOCO, JACOCO_ANALYSIS_MODEL_FILE);

verifyOneJacocoResult(job);
Expand Down Expand Up @@ -226,15 +226,15 @@ void shouldRecordTwoJacocoResultsInFreestyleJob() {
}

@Test
void shouldRecordTwoJacocoResultsInPipeline() {
void shouldRecordTwoJacocoResultsInPipeline() throws Exception {
WorkflowJob job = createPipeline(Parser.JACOCO,
JACOCO_ANALYSIS_MODEL_FILE, JACOCO_CODING_STYLE_FILE);

verifyTwoJacocoResults(job);
}

@Test
void shouldRecordTwoJacocoResultsInDeclarativePipeline() {
void shouldRecordTwoJacocoResultsInDeclarativePipeline() throws Exception {
WorkflowJob job = createDeclarativePipeline(Parser.JACOCO,
JACOCO_ANALYSIS_MODEL_FILE, JACOCO_CODING_STYLE_FILE);

Expand All @@ -260,14 +260,14 @@ void shouldRecordOneCoberturaResultInFreestyleJob() {
}

@Test
void shouldRecordOneCoberturaResultInPipeline() {
void shouldRecordOneCoberturaResultInPipeline() throws Exception {
WorkflowJob job = createPipeline(Parser.COBERTURA, COBERTURA_HIGHER_COVERAGE_FILE);

verifyOneCoberturaResult(job);
}

@Test
void shouldRecordOneCoberturaResultInDeclarativePipeline() {
void shouldRecordOneCoberturaResultInDeclarativePipeline() throws Exception {
WorkflowJob job = createDeclarativePipeline(Parser.COBERTURA, COBERTURA_HIGHER_COVERAGE_FILE);

verifyOneCoberturaResult(job);
Expand Down Expand Up @@ -310,7 +310,7 @@ void shouldRecordCoberturaAndJacocoResultsInFreestyleJob() {
}

@Test
void shouldRecordCoberturaAndJacocoResultsInPipeline() {
void shouldRecordCoberturaAndJacocoResultsInPipeline() throws Exception {
WorkflowJob job = createPipelineWithWorkspaceFiles(JACOCO_ANALYSIS_MODEL_FILE, COBERTURA_HIGHER_COVERAGE_FILE);

setPipelineScript(job,
Expand All @@ -323,7 +323,7 @@ void shouldRecordCoberturaAndJacocoResultsInPipeline() {
}

@Test
void shouldRecordCoberturaAndJacocoResultsInDeclarativePipeline() {
void shouldRecordCoberturaAndJacocoResultsInDeclarativePipeline() throws Exception {
WorkflowJob job = createPipelineWithWorkspaceFiles(JACOCO_ANALYSIS_MODEL_FILE, COBERTURA_HIGHER_COVERAGE_FILE);

job.setDefinition(new CpsFlowDefinition("pipeline {\n"
Expand Down Expand Up @@ -426,7 +426,7 @@ private void verifyOpenCoverResults(final Run<?, ?> build) {
}

@Test @Issue("JENKINS-72595")
void shouldGracefullyHandleBomEncodedFiles() {
void shouldGracefullyHandleBomEncodedFiles() throws Exception {
assumeThatTestIsRunningOnUnix();

var fileName = "opencover-with-bom.xml";
Expand All @@ -441,7 +441,7 @@ void shouldGracefullyHandleBomEncodedFiles() {
}

@Test
void shouldRecordOneNUnitResultInFreestyleJob() {
void shouldRecordOneNUnitResultInFreestyleJob() throws Exception {
FreeStyleProject project = createFreestyleJob(Parser.NUNIT, "nunit.xml");

Run<?, ?> build = buildSuccessfully(project);
Expand Down Expand Up @@ -546,7 +546,7 @@ private static CoverageBuilder createLineCoverageBuilder() {
}

@Test
void shouldRecordResultsWithDifferentId() {
void shouldRecordResultsWithDifferentId() throws Exception {
WorkflowJob job = createPipelineWithWorkspaceFiles(JACOCO_ANALYSIS_MODEL_FILE, COBERTURA_HIGHER_COVERAGE_FILE);

setPipelineScript(job,
Expand Down Expand Up @@ -581,7 +581,7 @@ void shouldRecordResultsWithDifferentId() {
}

@Test @Issue("785")
void shouldIgnoreErrors() {
void shouldIgnoreErrors() throws Exception {
WorkflowJob job = createPipeline();
copyFileToWorkspace(job, "cobertura-duplicate-methods.xml", "cobertura.xml");
job.setDefinition(new CpsFlowDefinition(
Expand All @@ -606,7 +606,7 @@ void shouldIgnoreErrors() {
}

@Test
void shouldIgnoreEmptyListOfFiles() {
void shouldIgnoreEmptyListOfFiles() throws Exception {
WorkflowJob job = createPipeline();
job.setDefinition(new CpsFlowDefinition(
"node {\n"
Expand All @@ -623,7 +623,7 @@ void shouldIgnoreEmptyListOfFiles() {
}

@Test
void shouldParseFileWithJaCoCo() {
void shouldParseFileWithJaCoCo() throws Exception {
WorkflowJob job = createPipeline();
copyFilesToWorkspace(job, "jacoco.xml");
job.setDefinition(new CpsFlowDefinition(
Expand Down Expand Up @@ -681,14 +681,14 @@ void shouldRecordOneVectorCastResultInFreestyleJob() {
}

@Test
void shouldRecordOneVectorCastResultInPipeline() {
void shouldRecordOneVectorCastResultInPipeline() throws Exception {
WorkflowJob job = createPipeline(Parser.VECTORCAST, VECTORCAST_HIGHER_COVERAGE_FILE);

verifyOneVectorCastResult(job);
}

@Test
void shouldRecordOneVectorCastResultInDeclarativePipeline() {
void shouldRecordOneVectorCastResultInDeclarativePipeline() throws Exception {
WorkflowJob job = createDeclarativePipeline(Parser.VECTORCAST, VECTORCAST_HIGHER_COVERAGE_FILE);

verifyOneVectorCastResult(job);
Expand Down Expand Up @@ -798,7 +798,7 @@ void shouldRecordVectorCastAndJacocoResultsInFreestyleJob() {
}

@Test
void shouldRecordVectorCastAndJacocoResultsInPipeline() {
void shouldRecordVectorCastAndJacocoResultsInPipeline() throws Exception {
WorkflowJob job = createPipelineWithWorkspaceFiles(JACOCO_ANALYSIS_MODEL_FILE, VECTORCAST_HIGHER_COVERAGE_FILE);

setPipelineScript(job,
Expand All @@ -811,7 +811,7 @@ void shouldRecordVectorCastAndJacocoResultsInPipeline() {
}

@Test
void shouldRecordVectorCastAndJacocoResultsInDeclarativePipeline() {
void shouldRecordVectorCastAndJacocoResultsInDeclarativePipeline() throws Exception {
WorkflowJob job = createPipelineWithWorkspaceFiles(JACOCO_ANALYSIS_MODEL_FILE, VECTORCAST_HIGHER_COVERAGE_FILE);

job.setDefinition(new CpsFlowDefinition("pipeline {\n"
Expand Down Expand Up @@ -893,7 +893,7 @@ private void verifyForOneVectorCastAndOneJacoco(final ParameterizedJob<?, ?> pro
}

@Test
void shouldRecordVerctorCastResultsWithDifferentId() {
void shouldRecordVerctorCastResultsWithDifferentId() throws Exception {
WorkflowJob job = createPipelineWithWorkspaceFiles(JACOCO_ANALYSIS_MODEL_FILE, VECTORCAST_HIGHER_COVERAGE_FILE);

setPipelineScript(job,
Expand Down Expand Up @@ -928,7 +928,7 @@ void shouldRecordVerctorCastResultsWithDifferentId() {
}

@Test
void shouldParseFileWithVectorCast() {
void shouldParseFileWithVectorCast() throws Exception {
WorkflowJob job = createPipeline();
copyFileToWorkspace(job, "vectorcast-statement-mcdc-fcc.xml", "xml_data/cobertura/coverage_results_test.xml");
job.setDefinition(new CpsFlowDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class CoverageTokenMacroITest extends AbstractCoverageITest {
@Test
void shouldUseQualityGateInPipeline() {
void shouldUseQualityGateInPipeline() throws Exception {
WorkflowJob project = createPipelineWithWorkspaceFiles(JACOCO_ANALYSIS_MODEL_FILE);

setPipelineScript(project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void shouldComputeDeltaInFreestyleJob() {
}

@Test
void shouldComputeDeltaInPipeline() {
void shouldComputeDeltaInPipeline() throws Exception {
WorkflowJob job = createPipeline(Parser.JACOCO, JACOCO_ANALYSIS_MODEL_FILE, JACOCO_CODING_STYLE_FILE);

Run<?, ?> firstBuild = buildSuccessfully(job);
Expand All @@ -60,7 +60,7 @@ void shouldComputeDeltaInPipeline() {
}

@Test
void shouldSelectResultByIdInReferenceBuild() {
void shouldSelectResultByIdInReferenceBuild() throws Exception {
WorkflowJob job = createPipelineWithWorkspaceFiles(
JACOCO_ANALYSIS_MODEL_FILE, JACOCO_CODING_STYLE_FILE,
"mutations.xml", "mutations-codingstyle.xml");
Expand Down
Loading

0 comments on commit 714c09d

Please sign in to comment.