Skip to content

Commit

Permalink
Merge pull request #234 from tszmytka/66684-generate-snippet
Browse files Browse the repository at this point in the history
[JENKINS-66684] Provide colorMapName to allow generating example snippet
  • Loading branch information
dblock authored Nov 7, 2021
2 parents 2b76927 + 90f4bfb commit e285fb3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
1.0.1 (Next)
============

* [JENKINS-66684](https://issues.jenkins.io/browse/JENKINS-66684) Pipeline syntax snippet generator fails with ansicolor plugin 1.0.0 - [@tszmytka](https://github.com/tszmytka).
* Your contribution here.


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ ansiColor('xterm') {

## In a traditional job

Traditional, Jenkins UI defined jobs can also take advantage of `ansicolor` by enabling under "Build Environment" settings.
Traditional, Jenkins UI defined jobs, can also take advantage of `ansicolor` by enabling it under "Build Environment" settings.

![enable](images/ansicolor-enable.png "Enable AnsiColor")

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/hudson/plugins/ansicolor/AnsiColorStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public AnsiColorStep(final String colorMapName) {
Optional.ofNullable(Jenkins.get().getDescriptorByType(AnsiColorBuildWrapper.DescriptorImpl.class).getGlobalColorMapName()).orElse(AnsiColorMap.DefaultName));
}

public String getColorMapName() {
return colorMapName;
}

private static DescriptorImpl getWrapperDescriptor() {
return Jenkins.get().getDescriptorByType(DescriptorImpl.class);
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/hudson/plugins/ansicolor/AnsiColorStepTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ public void canUseAndReportDefaultColorMapName() {
);
}

@Issue("JENKINS-66684")
@Test
public void canGetConstructorParametersForSnippetGenerator() {
final String colorMapName = AnsiColorMap.VGA.getName();
final AnsiColorStep step = new AnsiColorStep(colorMapName);
assertThat(step.getColorMapName()).isEqualTo(colorMapName);
}

private void assertOutputOnRunningPipeline(Collection<String> expectedOutput, Collection<String> notExpectedOutput, String pipelineScript) {
jenkinsRule.then(r -> {
final WorkflowJob project = jenkinsRule.j.jenkins.createProject(WorkflowJob.class, "p");
Expand Down

0 comments on commit e285fb3

Please sign in to comment.