Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new Jenkins baseline 2.462 #1834

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-pom</artifactId>
<version>8.6.0</version>
<version>9.0.0</version>
<relativePath />
</parent>

Expand All @@ -25,8 +25,8 @@
<changelist>-SNAPSHOT</changelist>
<module.name>${project.groupId}.warnings.ng</module.name>

<analysis-model-api.version>12.5.0</analysis-model-api.version>
<analysis-model-tests.version>${analysis-model-api.version}</analysis-model-tests.version>
<analysis-model-api.version>12.6.0-rc839.46d92a_4783a_5</analysis-model-api.version>
<analysis-model-tests.version>12.5.0</analysis-model-tests.version>
<pull-request-monitoring.version>335.v525cd64ec76b_</pull-request-monitoring.version>

<eclipse-collections.version>9.2.0</eclipse-collections.version>
Expand Down Expand Up @@ -95,6 +95,7 @@
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>plugin-util-api</artifactId>
<version>5.0.0-rc990.a_c915b_e8801a_</version>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
Expand Down Expand Up @@ -306,6 +307,7 @@
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>plugin-util-api</artifactId>
<version>5.0.0-rc990.a_c915b_e8801a_</version>
<scope>test</scope>
<classifier>tests</classifier>
<exclusions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import com.google.errorprone.annotations.CanIgnoreReturnValue;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import hudson.model.AbstractProject;
import hudson.model.FreeStyleProject;
Expand Down Expand Up @@ -100,14 +99,14 @@ void shouldCreateChecksDetailsWithNewIssuesAsAnnotations() {
}

private void configureScanner(final WorkflowJob job, final String fileName, final String parameters) {
job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " discoverReferenceBuild()\n"
+ " recordIssues tool: checkStyle(pattern: '**/" + fileName + "-*') "
+ parameters
+ "\n"
+ " }\n"
+ "}", true));
+ "}"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.util.PathUtil;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;

import io.jenkins.plugins.analysis.core.model.AnalysisResult;
Expand All @@ -32,12 +31,12 @@ void shouldCorrectlyParseJavacErrors() {

createFileInWorkspace(project, "Test.java", "public class Test {}");

project.setDefinition(new CpsFlowDefinition("node {\n"
project.setDefinition(createPipelineScript("node {\n"
+ " timestamps {\n"
+ " echo '[javac] Test.java:39: warning: Test Warning'\n"
+ " recordIssues tools: [java()], skipBlames: true\n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(project);

Expand Down Expand Up @@ -71,12 +70,12 @@ void shouldCorrectlyParseClangErrors() {

createFileInWorkspace(project, "test.c", "int main(void) { }");

project.setDefinition(new CpsFlowDefinition("node {\n"
project.setDefinition(createPipelineScript("node {\n"
+ " timestamps {\n"
+ " echo 'test.c:1:2: error: This is an error.'\n"
+ " recordIssues tools: [clang(id: 'clang', name: 'clang')], skipBlames: true\n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(project);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.junit.jupiter.api.Test;

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

Expand Down Expand Up @@ -44,7 +43,7 @@ void shouldExpandTokenMacro() {
void shouldExpandDifferentSeverities() {
WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("all-severities.xml");

job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " recordIssues tool: checkStyle(pattern: '**/" + "all-severities" + "*')\n"
+ " def total = tm('${ANALYSIS_ISSUES_COUNT}')\n"
Expand All @@ -58,7 +57,7 @@ void shouldExpandDifferentSeverities() {
+ " echo '[normal=' + normal + ']' \n"
+ " echo '[low=' + low + ']' \n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult baseline = scheduleBuildAndAssertStatus(job, Result.SUCCESS);

Expand Down Expand Up @@ -91,7 +90,7 @@ private void verifyConsoleLog(final AnalysisResult baseline, final int totalSize
}

private void configureToken(final WorkflowJob job, final String fileName) {
job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " discoverReferenceBuild()\n"
+ " recordIssues tool: checkStyle(pattern: '**/" + fileName + "*')\n"
Expand All @@ -106,6 +105,6 @@ private void configureToken(final WorkflowJob job, final String fileName) {
+ " echo '[new=' + additional + ']' \n"
+ " echo '[fixed=' + fixed + ']' \n"
+ " }\n"
+ "}", true));
+ "}"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import com.google.errorprone.annotations.CanIgnoreReturnValue;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import hudson.model.AbstractProject;
import hudson.model.FreeStyleProject;
Expand Down Expand Up @@ -48,14 +47,14 @@ class QualityGateITest extends IntegrationTestWithJenkinsPerSuite {
void shouldUseTwoQualityGates() {
WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("checkstyle1.xml", "checkstyle2.xml");

job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " recordIssues tools: [checkStyle(pattern: '**/*issues.txt')],\n"
+ " qualityGates: [\n"
+ " [threshold: 3, type: 'TOTAL', criticality: 'NOTE'],\n"
+ " [threshold: 7, type: 'TOTAL', criticality: 'ERROR']]\n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(job);
assertThat(result).hasTotalSize(6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class StepsITest extends IntegrationTestWithJenkinsPerSuite {
@Test
void shouldNotFailWhenJobHasNoWorkspace() {
var job = createPipelineWithWorkspaceFilesWithSuffix("eclipse.txt");
job.setDefinition(new CpsFlowDefinition("def r; node {r = scanForIssues tool: eclipse(pattern: '*issues.txt')}; publishIssues issues: [r]", true));
job.setDefinition(createPipelineScript("def r; node {r = scanForIssues tool: eclipse(pattern: '*issues.txt')}; publishIssues issues: [r]"));

var build = buildSuccessfully(job);
assertThat(build.getAction(ResultAction.class).getResult().getIssues()).hasSize(8);
Expand All @@ -81,12 +81,12 @@ void shouldNotFailWhenJobHasNoWorkspace() {
void shouldParseCheckstyleUsingTheParserRegistry() {
WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("checkstyle1.xml", "checkstyle2.xml");

job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " recordIssues tool: analysisParser(analysisModelId: 'checkstyle', pattern: '**/"
+ "checkstyle1" + "*')\n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult baseline = scheduleSuccessfulBuild(job);
assertThat(baseline).hasTotalSize(3);
Expand Down Expand Up @@ -157,7 +157,7 @@ void shouldWhitelistRecorderApi() {
}

private void configureRecorder(final WorkflowJob job, final String fileName) {
job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " discoverReferenceBuild()\n"
+ " def reports = recordIssues tool: checkStyle(pattern: '**/" + fileName
Expand All @@ -173,11 +173,11 @@ private void configureRecorder(final WorkflowJob job, final String fileName) {
+ " echo issue.toString()\n"
+ " }"
+ " }\n"
+ "}", true));
+ "}"));
}

private void configureScanner(final WorkflowJob job, final String fileName) {
job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " def report = scanForIssues tool: checkStyle(pattern: '**/" + fileName + "*')\n"
+ " echo '[total=' + report.size() + ']' \n"
Expand All @@ -189,7 +189,7 @@ private void configureScanner(final WorkflowJob job, final String fileName) {
+ " echo issue.getAuthorName()\n"
+ " }"
+ " }\n"
+ "}", true));
+ "}"));
}

/**
Expand All @@ -199,11 +199,11 @@ private void configureScanner(final WorkflowJob job, final String fileName) {
void shouldSkipBlaming() {
WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("checkstyle1.xml");

job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " recordIssues skipBlames: true, tool: checkStyle(pattern: '**/checkstyle1" + "*')\n"
+ " }\n"
+ "}", true));
+ "}"));
Run<?, ?> baseline = buildSuccessfully(job);
assertThat(getConsoleLog(baseline)).contains("Skipping SCM blames as requested");
}
Expand All @@ -214,13 +214,13 @@ void shouldSkipBlaming() {
void shouldToggleQuietStatusOfLogger(final boolean quiet) {
WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("checkstyle1.xml");

job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " recordIssues "
+ " quiet: " + quiet + ", "
+ " tool: checkStyle(pattern: '**/" + "checkstyle1" + "*')\n"
+ " }\n"
+ "}", true));
+ "}"));
Run<?, ?> baseline = buildSuccessfully(job);
String consoleLog = getConsoleLog(baseline);
String message = "[CheckStyle]";
Expand Down Expand Up @@ -272,7 +272,7 @@ private void verifyApiResults(final Run<?, ?> baseline, final int totalSize, fin

private void configurePublisher(final WorkflowJob job, final String fileName, final String qualityGate) {
String qualityGateParameter = String.format("qualityGates: [%s]", qualityGate);
job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " discoverReferenceBuild()\n"
+ " def issues = scanForIssues tool: checkStyle(pattern: '**/" + fileName + "*')\n"
Expand All @@ -289,7 +289,7 @@ private void configurePublisher(final WorkflowJob job, final String fileName, fi
+ " echo '[new=' + totals.getNewSize() + ']' \n"
+ " echo '[fixed=' + totals.getFixedSize() + ']' \n"
+ " }\n"
+ "}", true));
+ "}"));
}

/** Verifies that a {@link Tool} defines a {@link Symbol}. */
Expand All @@ -307,7 +307,7 @@ void shouldProvideSymbol() {
void shouldRunInDeclarativePipeline() {
WorkflowJob job = createPipeline();

job.setDefinition(new CpsFlowDefinition("pipeline {\n"
job.setDefinition(createPipelineScript("pipeline {\n"
+ " agent 'any'\n"
+ " stages {\n"
+ " stage ('Create a fake warning') {\n"
Expand All @@ -321,7 +321,7 @@ void shouldRunInDeclarativePipeline() {
+ " recordIssues tool: gcc4(pattern: 'warnings.log')\n"
+ " }\n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(job);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import org.junit.jupiter.api.Test;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import hudson.model.Run;
import hudson.model.Slave;
Expand Down Expand Up @@ -45,10 +44,10 @@ void shouldCopySourcesIfMasterAgentSecurityIsActive() {

createFileInAgentWorkspace(agent, project, "Test.java", JAVA_CONTENT);

project.setDefinition(new CpsFlowDefinition("node('agent') {\n"
project.setDefinition(createPipelineScript("node('agent') {\n"
+ " echo '[javac] Test.java:39: warning: Test Warning'\n"
+ " recordIssues tool: java(), skipBlames: true\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(project);
assertThat(result).hasNoErrorMessages();
Expand Down Expand Up @@ -112,10 +111,10 @@ void shouldNotCopySourcesWhenSourceCodeRetentionIsNever() {

createFileInAgentWorkspace(agent, project, "Test.java", JAVA_CONTENT);

project.setDefinition(new CpsFlowDefinition("node('agent') {\n"
project.setDefinition(createPipelineScript("node('agent') {\n"
+ " echo '[javac] Test.java:39: warning: Test Warning'\n"
+ " recordIssues tool: java(), sourceCodeRetention: 'NEVER'\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(project);
assertThat(result).hasNoErrorMessages();
Expand Down
Loading