Skip to content
Open
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 @@ -91,7 +91,7 @@ public class LibraryStep extends Step {
private static final Logger LOGGER = Logger.getLogger(LibraryStep.class.getName());

private final String identifier;
private Boolean changelog = true;
private Boolean changelog;
private LibraryRetriever retriever;

@DataBoundConstructor public LibraryStep(String identifier) {
Expand Down Expand Up @@ -222,7 +222,7 @@ else if (retriever instanceof SCMRetriever) {
if (retriever instanceof SCMBasedRetriever) {
libraryPath = ((SCMBasedRetriever) retriever).getLibraryPath();
}
LibraryRecord record = new LibraryRecord(name, version, trusted, changelog, cachingConfiguration, source, libraryPath);
LibraryRecord record = new LibraryRecord(name, version, trusted, Boolean.TRUE.equals(changelog), cachingConfiguration, source);
LibrariesAction action = run.getAction(LibrariesAction.class);
if (action == null) {
action = new LibrariesAction(Lists.newArrayList(record));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,37 @@ public class LibraryStepTest {
assertEquals("[LibraryRecord{name=otherstuff, version=master, variables=[x], trusted=false, changelog=false, cachingConfiguration=null, directoryName=" + directoryName + "}]", action.getLibraries().toString());
}

@Test public void changelog() throws Exception {
sampleRepo.init();
sampleRepo.write("vars/x.groovy", "def call() {echo 'ran library'}");
sampleRepo.git("add", "vars");
sampleRepo.git("commit", "--message=init");
LibraryConfiguration libraryConfiguration = new LibraryConfiguration("stuff", new SCMSourceRetriever(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", true)));
GlobalLibraries.get().setLibraries(Collections.singletonList(libraryConfiguration));
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("library 'stuff@master'; x()", true));
WorkflowRun b = r.buildAndAssertSuccess(p);
assertTrue(b.getAction(LibrariesAction.class).getLibraries().get(0).changelog);
b = r.buildAndAssertSuccess(p);
assertTrue(b.getAction(LibrariesAction.class).getLibraries().get(0).changelog);
p.setDefinition(new CpsFlowDefinition("library changelog: true, identifier: 'stuff@master'; x()", true));
b = r.buildAndAssertSuccess(p);
assertTrue(b.getAction(LibrariesAction.class).getLibraries().get(0).changelog);
p.setDefinition(new CpsFlowDefinition("library changelog: false, identifier: 'stuff@master'; x()", true));
b = r.buildAndAssertSuccess(p);
assertFalse(b.getAction(LibrariesAction.class).getLibraries().get(0).changelog);
libraryConfiguration.setIncludeInChangesets(false);
p.setDefinition(new CpsFlowDefinition("library 'stuff@master'; x()", true));
b = r.buildAndAssertSuccess(p);
assertFalse(b.getAction(LibrariesAction.class).getLibraries().get(0).changelog);
p.setDefinition(new CpsFlowDefinition("library changelog: true, identifier: 'stuff@master'; x()", true));
b = r.buildAndAssertSuccess(p);
assertTrue(b.getAction(LibrariesAction.class).getLibraries().get(0).changelog);
p.setDefinition(new CpsFlowDefinition("library changelog: false, identifier: 'stuff@master'; x()", true));
b = r.buildAndAssertSuccess(p);
assertFalse(b.getAction(LibrariesAction.class).getLibraries().get(0).changelog);
}

@Test public void classes() throws Exception {
sampleRepo.init();
sampleRepo.write("src/some/pkg/Lib.groovy", "package some.pkg; class Lib {static class Inner {static String stuff() {Constants.CONST}}}");
Expand Down
Loading