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-66684] Provide colorMapName to allow generating example snippet #234

Merged
merged 3 commits into from
Nov 7, 2021
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
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
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are actually better test utilities in workflow-step-api and workflow-cps.

}

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