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
Conversation
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
(cherry picked from commit 432f56c)
There are still some bugs to be fixes:
|
@@ -39,37 +51,51 @@ public String generatePipeline(InputStream yamlScriptInputStream, GitConfig gitC | |||
scriptLines.add("stage('Build') {"); |
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
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?
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 |
Not sure how to remove the findbugs error. |
There was a problem hiding this 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
There was a problem hiding this 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
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