Skip to content

Commit

Permalink
Fix issue #22
Browse files Browse the repository at this point in the history
pipeline-maven is declared as optional, but jenkins injection fails
at startup time looking for pipeline-maven configuration.
  • Loading branch information
guidograzioli committed Feb 13, 2020
1 parent 47cc074 commit a797831
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@
public class PipelineGraphPublisherEdgeProvider implements EdgeProvider {

private final Jenkins jenkins;
private final GlobalPipelineMavenConfig globalPMConfig;
private final boolean isPluginInstalled;
private final static Logger LOGGER = Logger.getLogger(PipelineGraphPublisherEdgeProvider.class.getName());

@Inject
public PipelineGraphPublisherEdgeProvider(Jenkins jenkins) {
this.jenkins = jenkins;
this.globalPMConfig = ExtensionList.lookupSingleton(GlobalPipelineMavenConfig.class);
this.isPluginInstalled = jenkins.getPlugin("pipeline-maven") != null;
}

Expand All @@ -64,6 +62,7 @@ public Iterable<Edge> getUpstreamEdgesIncidentWith(Job<?, ?> project) {
if (!isPluginInstalled) {
return edges;
}
GlobalPipelineMavenConfig globalPMConfig = ExtensionList.lookupSingleton(GlobalPipelineMavenConfig.class);
if (globalPMConfig != null && project instanceof WorkflowJob) {
PipelineMavenPluginDao dao = globalPMConfig.getDao();
if (project.getLastSuccessfulBuild() != null) {
Expand All @@ -83,6 +82,10 @@ public Iterable<Edge> getUpstreamEdgesIncidentWith(Job<?, ?> project) {
@Override
public Iterable<Edge> getDownstreamEdgesIncidentWith(Job<?, ?> project) {
List<Edge> edges = new ArrayList<>();
if (!isPluginInstalled) {
return edges;
}
GlobalPipelineMavenConfig globalPMConfig = ExtensionList.lookupSingleton(GlobalPipelineMavenConfig.class);
if (globalPMConfig != null && project instanceof WorkflowJob) {
PipelineMavenPluginDao dao = globalPMConfig.getDao();
if (project.getLastSuccessfulBuild() != null) {
Expand Down

0 comments on commit a797831

Please sign in to comment.