Hi all, We've been using Go CD for a few months now, using the default Perforce material provided. It's missing a few features, so we decided to look into making a more fully fleshed-out plugin.
A number of issues have come up, most of which we've managed to overcome. The last few issues though, we're stuck with, so here they are; hopefully someone has some insights :) Validation Response First up, the response our plugin is sending to the Go CD server, to the validate-scm-configuration request, is somehow not being correctly handled. >From what I understand from the documentation <https://developer.gocd.org/16.3.0/writing_go_plugins/scm_material/version_1_0/validate_scm_configuration.html>, this request should be used to validate that the data the user enters into the plugin's material configuration, is correct. For example we need the user's Perforce account username and password, as well as the server address and port. Anything incorrect, as far as I see from the docs, should be sent back in this form: [ { "key": "SCM_URL", "message": "SCM URL not specified" }, { "key": "RANDOM", "message": "Unsupported key(s) found : RANDOM. Allowed key(s) are : SCM_URL, USERNAME, PASSWORD" } ] An array of objects containing *key * and *message*, where *key* matches the field's name, and *message* is an error related to what the user put in that field. This is exactly what we're sending back (copied from our logs): [ { "key": "username", "message": "Perforce account username is required" }, ] Which looks the same to me. We then have our template, which is much like the one found in one of the SCM plugin examples <https://github.com/TWChennai/gocd-git-path-material-plugin>, which looks like this: <div class="form_item_block"> <label>Username:<span class="asterisk">*</span></label> <input type="text" ng-model="username" ng-required="true"/> <span class="form_error" ng-show="GOINPUTNAME[username].$error.server">{{ GOINPUTNAME[username].$error.server }}</span> </div> Perhaps there's something wrong here, but we can't figure out what. The behaviour we see, when we fail to enter a username, is that it just saves the configuration without error. We don't see any red error text appear next to the relevant field. The plugin will then fail later on, once it tries to perform any operations that require the password, as you would expect. Checkout Step The second is related to how the checkout command is supposed to work. From the docs <https://developer.gocd.org/16.3.0/writing_go_plugins/scm_material/version_1_0/checkout.html>, we assume that this request should trigger the actual checking out of code and assets from the repository. The request expects a response containing a status of either success or failure, and an optional list of error messages in case of failure. Every other request is implemented, and appears to be working without error. However, on triggering the pipeline with our plugin as a material, on trying to checkout, we get the following error in the first stage's log: Interaction with plugin with id 'PerforceMaterial' implementing 'scm' extension failed while requesting for 'checkout'. Reason: [Unable to de-serialize json response. Empty response body] Which seems pretty clear, except that, as far as we can see, the *checkout* request *never arrives at our plugin.* We're logging the name of all incoming requests, and we see all the other requests come in and get dealt with. The request for latest revisions since a particular revision is coming in, and we're sending a response; we also see that this is handled correctly, as we see the changes in Go CD's web interface for the triggered build in question. However, *checkout* never shows up. Therefore this part of our code is never being called. So what JSON response is the error message above talking about? While looking into this, we grabbed the source for the Git Path Material Plugin, linked earlier, compiled it with some extra logging in (specifically in the request handler for the checkout request), added it to our Go CD server, and had a look in the logs after using it in a pipeline. It also never logged that the checkout request had ever arrived, yet the plugin did successfully checkout the repository. After looking in more detail at the code for that plugin, it seems that Git Path Material Plugin actually does a fetch or clone call inside the *latest revisions since* request. Is this the intended behaviour, and the docs are just a bit out of date? More info on this would be really appreciated! Thanks for your time. -- You received this message because you are subscribed to the Google Groups "go-cd" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
