Hi all. I'm trying to write a Go CD SCM plugin; currently I exported a simple plugin, and it appears in the Admin > Plugins section. However it doesn't appear in the list when I try to choose a source for a material.
I should say, I'm using Kotlin instead of Java, not sure if that would be a problem.
I'm handling the "scm-configuration" request and sending back basically the same stuff I found in the SCM example, that I found through the Go CD docs.
Still, it doesn't appear in that list. Any ideas?
hump joined the channel
hump
Anyone here?
hump has quit
moritz has quit
arvindsv
butts_butts: Did you see any error in the plugins page? Any logs in the log dir?
butts_butts
arvindsv: there were no errors in the plugins page, no. I'll check the logs now.
arvindsv: so there are a bunch of ERROR logs, related to plugins, with messages like "Failed to fetch Plugin Settings metadata for plugin : cd.go.authentication.passwordfile java.lang.RuntimeException: Interaction with plugin with id 'cd.go.authentication.passwordfile' implementing 'authorization' extension failed while requesting for 'go.plugin-settings.get-configuration'. Reason: [The plugin sent a response that could not be understood by Go. Plugin
Maybe check while editing a pipeline to add a material?
butts_butts
Ah. Actually I was always looking in the list via editing an existing pipeline. I just tried adding a new pipeline to see if it worked that way, but it also doesn't show up there.
So, both places.
arvindsv
Is the code available somewhere? Or is it going to be private?
That's what it uses to figure out which class to send the message to (and create an instance of).
butts_butts
Yup, I have the @Extension annotation.
I think it is getting loaded by Go, because I see it in Admin > Plugins.
Also, if I don't implement `pluginIdentifier`, an error shows up in the Admin > Plugins section for my plugin.
I'll try throwing in the handle function.
- I should mention, I'm primarily a c++ programmer; this is the first time I've dabbled in the Java world
Quite possible I'm building the jar incorrectly or something. In IntelliJ IDEA, I'm using build artifact.
arvindsv
:) That's ok. You're doing well so far. This is not your fault. GoCD should be telling you what's going on.
butts_butts
:)
arvindsv
Yeah, throw in the handle function and let's see.
butts_butts
When I setup the build artifact stuff in IDEA, it wouldn't let me choose my the entry point file, unless that file had a main function inside it, so I added an empty one. Not sure if that can cause any issues?
arvindsv
No, that should be ok.
butts_butts
Ok, throwing an IllegalArugumentException in that function; loading now.
Interaction with plugin with id 'TestMaterial' implementing 'scm' extension failed while requesting for 'scm-configuration'. Reason: [null]
Do you now see a message in the logs? "Failed to fetch SCM metadata for plugin ..."
In the server los.
logs*
butts_butts
Will check
Yup!
Ok.
So it's definitely getting into there.
arvindsv
Ok, good. Can you check the logs to see if you had any messages earlier about this?
butts_butts
Yup
Well, if you mean before I put in the exception? This definitely wasn't in the logs then
I searched for some keywords that didn't appear then, that are there now
arvindsv
I see. And, were you handling the 'scm-view' call too, earlier?
The displayValue in the response to 'scm-view' is what is supposed to show up in the dropdown.
I guess you have. Otherwise, you'd see the message: "Failed to fetch SCM metadata for plugin"
butts_butts
I was handling "scm-view" earlier, like a few days ago. Then I removed everything except for "scm-configuration" to try and nail down what was failing.
So currently no, I'm not handling scm-view. I assumed that scm-view was the Angular view that would show up if you added the material to a pipeline; the UI that you would enter the repository location, etc?
arvindsv
Right. But, the 'displayValue' in that response to scm-view is important. It's needed for the dropdown.
Hope so! Kotlin seems like quite a nice language, lots of syntactic sugar.
Ok, some progress
I'm now getting "Failed to fetch Plugin Settings metadata for plugin"
I'm handling only scm-view and scm-configuration, and from looking a bit at the Go source, I guess this error is because I'm not handling one of the other messages.
Ok, so the problem was
In my `handle` function, I was returning a response with the not-found code (404), if one of the messages wasn't handled.
I did that because Kotlin wouldn't let me return `null`, and the fix for this is adding ? to the return type for the `handle` function, so that I can return null.
Now, returning null for unimplemented requests, I get errors in the log.
Now I'll test to see if the Kotlin `when` syntax will work.
Yup, when syntax works.
Now I'll add back the implementations of the other requests... and hopefully....
arvindsv
Ok good!
butts_butts
This "Plugin Settings metadata" error, is that about the response to validate-scm-configuration?
arvindsv
What else does it say?
It's about either the config or the view messages.
Not about validate.
moritz joined the channel
butts_butts
"2017-06-26 17:18:31,543 ERROR [Thread-75] PluginSettingsMetadataLoader:77 - Failed to fetch Plugin Settings metadata for plugin : TestPlugin java.lang.RuntimeException: Interaction with plugin with id 'TestPlugin' implementing 'scm' extension failed while requesting for 'go.plugin-settings.get-configuration'. Reason: [The plugin sent a null response]"
It's saying I sent a null response to one of the requests, view or config?
arvindsv
Are you handling the go.plugin-settings.get-configuration message?
That's what it is sending.
And, it's saying you returned false.
null, sorry.
I think I know what's going on.
It's documented wrong.
I thought we moved it out of that place, but it's not.
I'll look at it in a few mins.
And fix it.
I'll need to go see when it changed.
butts_butts
Oh? The request name or what?
arvindsv
The problem is that there are two pieces of configuration.
One is the response to: go.plugin-settings.get-configuration
That is what shows up in the plugin settings.
A little gear next to the name of the plugin in Admin -> Plugins.