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

JENKINS-68740: Support ansible-lint >=6.1.0 warning format #804

Merged
merged 1 commit into from
Jun 12, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class AnsibleLintParser extends LookaheadParser {
private static final long serialVersionUID = 8481090596321427484L;

private static final String ANSIBLE_LINT_WARNING_PATTERN = "(.*)\\:([0-9]*)\\:\\s*\\[?([a-zA-Z0-9\\-]+)\\]?\\s(.*)";
private static final String ANSIBLE_LINT_WARNING_PATTERN = "(.*)\\:([0-9]*)\\:\\s*\\[?([a-zA-Z0-9\\-]+)\\]?:?\\s(.*)";

/**
* Creates a new instance of {@link AnsibleLintParser}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AnsibleLintParserTest extends AbstractParserTest {

@Override
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
assertThat(report).hasSize(9);
assertThat(report).hasSize(10);

Iterator<Issue> iterator = report.iterator();
softly.assertThat(iterator.next())
Expand Down Expand Up @@ -86,6 +86,14 @@ protected void assertThatIssuesArePresent(final Report report, final SoftAsserti
.hasLineEnd(11)
.hasMessage("File permissions unset or incorrect")
.hasFileName("/workspace/templates.yml");

softly.assertThat(iterator.next())
.hasSeverity(Severity.WARNING_NORMAL)
.hasCategory("no-changed-when")
.hasLineStart(41)
.hasLineEnd(41)
.hasMessage("Commands should not change things if nothing needs doing.")
.hasFileName("/workspace/roles/create_service/tasks/main.yml");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void shouldFindAllAjcIssues() {
/** Runs the AnsibleLint parser on an output file that contains 9 issues. */
@Test
void shouldFindAllAnsibleLintIssues() {
findIssuesOfTool(9, "ansiblelint", "ansibleLint.txt");
findIssuesOfTool(10, "ansiblelint", "ansibleLint.txt");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
/workspace/system.yml:20: risky-file-permissions File permissions unset or incorrect
/workspace/upgrade.yml:38: no-handler Tasks that run when changed should likely be handlers
/workspace/templates.yml:11: risky-file-permissions File permissions unset or incorrect

/workspace/roles/create_service/tasks/main.yml:41: no-changed-when: Commands should not change things if nothing needs doing.