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-52491] - PipelineGenerator extensibility and support of custom sections #25

Merged
merged 7 commits into from Aug 12, 2018

Conversation

oleg-nenashev
Copy link
Member

@oleg-nenashev oleg-nenashev commented Aug 2, 2018

This is a result of the screenshare with @gautamabhishek46 and @martinda . We created a base extension engine and added support of custom pipeline sections defined as extensions. Also, some refactoring

  • - PipelineGenerator extension point
  • - Implementation for agent
  • - Custom sections support
  • - Detach all other generator code to extensions
  • - Add annotations in methods
  • - Fix the exception propagation, use the new type
  • - Add extra unit tests

Copy link

@kwhetstone kwhetstone left a comment

Choose a reason for hiding this comment

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

Overall, this looks great. Is the plan to do all the conversions in this ticket, or to start out with these changes and then do the other elements in a second PR?

@@ -116,4 +122,13 @@ public void setPost(Post post) {
public void setSteps(ArrayList<LinkedHashMap<String, Object>> steps) {
this.steps = Stage.generateSteps(steps);
}

public void setSections(@CheckForNull ArrayList<CustomPipelineSection> sections) {

Choose a reason for hiding this comment

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

Would it make sense to have an addSection method?

@@ -399,7 +387,7 @@ private Sequence doMappingForSequence(List<Object> objects) throws NotSupportedE
return snippetLines;
}

public String autoAddTabs(ArrayList<String> snippetLines) {
public static String autoAddTabs(ArrayList<String> snippetLines) {

Choose a reason for hiding this comment

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

Random implementation question: do we need to to call this outside of displaying the pipeline to end users? Declarative does a fairly good job surrounding things with curly braces. Does this become more of a "prettyPrint" detail?

agentLines.add("agent any");
} else if (agent.getAnyOrNone() != null)
agentLines.add("agent " + agent.getAnyOrNone());
else if(agent.isNone()) {

Choose a reason for hiding this comment

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

I'm still not sure why we have 2 checks here. getAnyOrNone() literally returns any or none. We should never reach this last check.

return object instanceof Agent;
}

private List<String> getCommonOptionsOfAgent(Agent agent) {

Choose a reason for hiding this comment

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

For getting this to work for now, this is good. I think there's a way to get this from the extension point this matches. I'd have to dig though; you could probably even ask on irc.

@oleg-nenashev
Copy link
Member Author

There are still some bugs to be fixes:

[INFO] Total bugs: 3

[INFO] gitConfig must be non-null but is marked as nullable [io.jenkins.plugins.sprp.generators.GitPushStageGenerator] At GitPushStageGenerator.java:[lines 21-32] NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE

[INFO] reportsAndArtifactsInfo must be non-null but is marked as nullable [io.jenkins.plugins.sprp.generators.PublishReportsAndArtifactsStageGenerator] At PublishReportsAndArtifactsStageGenerator.java:[lines 24-54] NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE

[INFO] stage must be non-null but is marked as nullable [io.jenkins.plugins.sprp.generators.StageGenerator] At StageGenerator.java:[lines 29-54] NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE

[INFO] 

@martinda martinda mentioned this pull request Aug 7, 2018
@@ -39,37 +51,51 @@ public String generatePipeline(InputStream yamlScriptInputStream, GitConfig gitC
scriptLines.add("stage('Build') {");

Choose a reason for hiding this comment

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

Random question: would it be possible to identify that there are only steps defined earlier and to create a Stage with those steps, assigning it to a value in yamlPipeline therefore eliminating these 2 implementation paths? Or is that more trouble than it's worth?

}
}

// Archive artifacts stage
scriptLines.addAll(psg.getArchiveArtifactsStage(yamlPipeline.getArchiveArtifacts()));
scriptLines.addAll(PipelineGenerator.convert("archiveArtifactStage", yamlPipeline.getArchiveArtifacts()));

Choose a reason for hiding this comment

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

Should this really continue to act different than the other stages? Isn't it just another stage at this point?

@kwhetstone
Copy link

Just a few general comments about the code that could be addressed in another PR. There's a lot going on here. I do really appreciate all the tests

@gautamabhishek46
Copy link
Contributor

Not sure how to remove the findbugs error.

Copy link
Member Author

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

When you use @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"), it pretty much always means suppression of a real issue in the code

Copy link
Member Author

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Test code is still improperly handled/annotated by FB warnings, but it is not a big deal. IMO it is ready to go

@gautamabhishek46 gautamabhishek46 merged commit 753acc6 into master Aug 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants