-
Notifications
You must be signed in to change notification settings - Fork 148
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
Add option to include causes in the JCasC export, and read causes from it on import. #139
base: master
Are you sure you want to change the base?
Conversation
66870b5
to
e737d80
Compare
e737d80
to
c5d4228
Compare
src/main/java/com/sonyericsson/jenkins/plugins/bfa/PluginImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/com/sonyericsson/jenkins/plugins/bfa/PluginImpl.java
Outdated
Show resolved
Hide resolved
Looking forward for this feature to be added in the plugin. I have added some minor review comments. |
d6c622b
to
c260c2a
Compare
@rsandell, @TWestling, folks, can you please take a look? Thanks! |
* Get if causes from the current knowledge base should be included in the JCasC export is enabled. | ||
* @return exportCausesToJCasCEnabled - on or off. null == off. | ||
*/ | ||
public boolean getExportCausesToJCasCEnabled() { |
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.
Java bean standard:
public boolean getExportCausesToJCasCEnabled() { | |
public boolean isExportCausesToJCasCEnabled() { |
*/ | ||
public Collection<FailureCause> getCauses() { | ||
// The Causes export can be very large so we only include it if enabled. | ||
if (!getExportCausesToJCasCEnabled()) { |
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.
if (!getExportCausesToJCasCEnabled()) { | |
if (!isExportCausesToJCasCEnabled()) { |
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.
Ah, I didn't realize JCasC's reflection would find methods starting with is
.
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.
It is the Java bean standard :)
* @param comment the comment of this FailureCause. | ||
* @param lastOccurred the time at which this FailureCause last occurred. | ||
* @param categories the categories of this FailureCause. | ||
* @param indications the list of indications | ||
* @param modifications the modification history of this FailureCause. | ||
*/ | ||
@DataBoundConstructor | ||
public FailureCause(String id, String name, String description, String comment, |
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.
public FailureCause(String id, String name, String description, String comment, | |
@Deprecated | |
public FailureCause(String id, String name, String description, String comment, |
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 don't know if this is really Deprecated, the fewer parameter DataBoundConstructor and the added DataBoundSetters allow JCasC to handle optional fields, but this constructor is a lot nicer to use in code.
Though if you still want it Deprecated that's fine too.
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.
The deprecation in this scenario would only be a flag to anyone coding against it that it is not the one actually used in runtime. It can still be used in tests, just annotated with something if sportbugs or checkstyle complains.
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.
Sorry for the delay in reviewing. So much to do and so little time.
if (knowledgeBase != null) { | ||
for (FailureCause cause:causes) { | ||
try { | ||
knowledgeBase.saveCause(cause); |
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 am quite certain this will create duplicates for anything else than the file based knowledge base. Unless the id
field is set. At least the javadoc should reflect that.
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.
Writing a unit test for that should be relatively easy. There are a couple of integration tests using an embedded mongodb that you can take inspiration from.
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've added a note about duplicates to the javadoc, there isn't much I can do about missing ids short of skipping entries that don't have one, thoughts on the preferred behavior?
c260c2a
to
b35c395
Compare
…xternal resource.
fd9db07
to
39d287f
Compare
So I'm having a bit of a hygiene problem with the port embedded mongodb runs on. But I'm not able to think of a good way to inject that port number into the config, it's a resource so I can't change it at runtime, and there aren't any hooks in JenkinsConfiguredWithCodeRule or ConfigurationAsCode to apply a transform after it gets loaded but before it's parsed. Only improvement I could think of would be to swap 27017 with something that's not the mongodb default port to lower the odds of collision but that's not a real solution. Thoughts? |
@allenbenz, use |
Looking forward for this feature to be added in the plugin. |
We're unable to deploy this plugin across our fleet without this functionality. |
@jhaxon As it seems like the original author has abandoned the change anyone is welcome to continue to work on it to get it over the finish line :) |
@allenbenz , @rsandell is there any plan to include this feature on further versions of this plugin? Thank you in advance 😃 |
@carlosgv87 unfortunately I have long since stopped working at the place where I was using Jenkins. If someone else wants to pick this up and finish it they should feel welcome to do so. My changes are MIT licensed so ownership isn't a concern for the next person. |
This adds an option to write causes to the JCasC config.
This also allows causes to be read from the JCasC config and is not gated behind enabling the write to JCasC option.
My use case for this is to workaround an issue where how I deploy jenkins causes JCasC to rewrite the plugin configurations - which erases the local knowledge base.
There are other more valid use cases such as wanting to version control the causes list that this provides for
Made it an option as a few dozen causes makes the JCasC export very long.
Some concerns I have that I was unable to resolve:
new Date(time)
line inFailureCauseModification.java
is parsingDate.toString()
output. This should be safe as long as the locale of the jenkins master doesn't change.