Skip to content

Commit

Permalink
Merge pull request #804 from Tobisaninfo/bugfix/JENKINS-68740
Browse files Browse the repository at this point in the history
JENKINS-68740: Support ansible-lint >=6.1.0 warning format
  • Loading branch information
uhafner authored Jun 12, 2022
2 parents cef1242 + babb012 commit c47ee7b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
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.

0 comments on commit c47ee7b

Please sign in to comment.