Tasks Plugin: Form help text & placeholders

49 views
Skip to first unread message

Joel Bodenmann

unread,
Dec 1, 2020, 8:49:45 AM12/1/20
to go-cd
Hi,

I am currently writing a tasks plugin.

I was wondering how I can add help text under the form elements in the AngularJS task view template? I am talking about the slightly-gray, smaller text that can be found under the input boxes of the config views of existing tasks such as the `Custom Command` task which adds information under each field.

Furthermore, how can I set the place-holder for a string input text? Eg. the `Custom Command` view has `ls` as the place holder in the `Command` input box.


Best regards,
~ Joel

mahesh....@gmail.com

unread,
Dec 2, 2020, 1:33:27 AM12/2/20
to go-cd
Hello,

The GoCD ECS Elastic Agent Plugin's Cluster Profile[1] view has few things that you are looking for. Maybe you can consider referring to it.


Thanks,
Mahesh

Joel Bodenmann

unread,
Dec 2, 2020, 9:01:00 AM12/2/20
to go-cd
Great, this will definitely be of help :)
Would be nice if GoCD would have some official documentation for this tho!


Thank you a lot & Best regards,
~ Joel

Aravind SV

unread,
Dec 2, 2020, 9:09:31 AM12/2/20
to Joel Bodenmann, go-cd

Agree!

The source of the current documentation is:
https://github.com/gocd/plugin-api.go.cd/blob/master/source/includes/shared/_angular-templates.md

It looks like this:
https://plugin-api.gocd.org/current/tasks/

Pull requests are always welcome. Not just from Joel. :) But, for anyone who finds that the documentation can be improved.

Cheers,
Aravind

Joel Bodenmann

unread,
Dec 2, 2020, 11:00:27 AM12/2/20
to go-cd
Aravind,

I've come across that piece of documentation when starting to look at the possibility of creating my own Task plugin. In my opinion the documentation does a good job at giving a quick overview but I found that some more advanced/complex examples might be helpful.
Once I gathered the necessary experience to finish my first plugin I'll look into providing a PR extending the documentation.

I am not a web developer so please forgive me if I should really not ask this here but: I managed to get everything working so far. I've a task plugin with the HTML config view that uses HTML input fields of type text and number  to configure my task. So far so good.
Next I wanted to add a checkbox for some conditional task behavior. However, I can't manage to get the checkbox to save to the XML. I've copied the fragments of my other text and number fields and simply changed the type to checkbox and adjusted the ng-model attribute to "link" to the new boolean setting.

Is there anything special about getting back the checked/unchecked state of a checkbox?

This is my HTML fragment for the checkbox:

    <div class="form_item_block">
          <input type="checkbox" ng-model="perform_build" ng-required="false"/>
          <label>Enable</label>
      </div>

If I look at the config form using the inspector I can see that my text and number input fields still have the ng-* attributes but the checkbox in question has been stripped of the ng-model and ng-required attribute.

I'd appreciate it a lot if somebody could help out an embedded C++ developer here not accustomed to work with AngularJS.


Best regards,
~ Joel

Joel Bodenmann

unread,
Dec 2, 2020, 12:40:55 PM12/2/20
to go-cd
Never mind - got it working. I needed to specify ng-true-value and ng-false-value to strings that Java's Boolean.parseBoolean() can understand.

Now the only thing left is fixing the issue that my number input is not set to the value from the XML (although it is being saved correctly) when opening the task config view. It's always empty (showing the placeholder) instead of displaying the value from the XML config.


Best regards,
~ Joel

Aravind SV

unread,
Dec 2, 2020, 1:49:07 PM12/2/20
to go-cd
Yes, it's complicated because it's an Angular template with its own syntax. This is so that a plugin can provide the template. If you have code publicly available, I might be able to take a look in a couple of days.

By the way: I'm a big opponent (is that the right word a non-proponent?) of task plugins. I think they shouldn't exist / be used. I rant about them often. Here's one of them: https://groups.google.com/d/topic/go-cd/9bmEV3R7JBk/discussion. It's very different from how (for instance) the Jenkins world thinks about plugins. I'd really consider pipelines as code or simple shell scripts instead of task plugins.

Cheers,
Aravind

--
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 go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/e316992e-3e4a-44c9-aa4c-6c5cb36e6733n%40googlegroups.com.

Joel Bodenmann

unread,
Dec 2, 2020, 5:03:23 PM12/2/20
to go-cd
Well, I literally just finished publishing the first version of my task plugin (see my other conversation announcing it). So this is a bit of a bummer now... :-(
I guess I'm gonna sleep a night over it but I think pulling back the new plugin would be a bit of a shame.

I fully understand where you come from and I am certainly far from qualified to take place in any kind of discussion like that as I am brand new to GoCD. I am coming from Jenkins so I might be a bit biased from that side as you also explained.


Best regards,
~ Joel

Aravind SV

unread,
Dec 2, 2020, 5:12:28 PM12/2/20
to go...@googlegroups.com
You certainly don’t need to pull it. :) You should submit a PR to get it listed on the site too.

I’d urge you and others to not depend on task plugins, because it ties you to the tool unnecessarily. That’s all.

I’ve seen others ask: “Why isn’t there a plug-in for X??” before and understanding the reason for it helps sometimes.

Cheers,
Aravind

Joel Bodenmann

unread,
Dec 2, 2020, 5:32:06 PM12/2/20
to go-cd
I've sent off the PR to get it listed in the meantime :)

Before starting to invest time writing this task plugin I tried to do my homework as best as I could. I did not find as much documentation / guides / general resources on GoCD as I expected. Therefore, writing this plugin is/was also a good way of getting to know GoCD better.
Other than that: If I get GoCD to do what I want I'll have several dozen C++ projects to manage with intricate dependencies. I expect to end up with about 100 pipelines. Templates certainly help a lot but there are certain limitations such as no possibility to extend a template (creating a template from another template / nested templates) and I already got tired of creating the custom command(s) for my cmake builds every time. This plugin is merely taking away some of the pain when defining new templates as I can't really re-use existing ones (other than copy-pasting the XML).

I fully understand that I could achieve everything I want (in terms of functionality that is) by simply going with the Custom Commands and in-repo scripts. CMake itself already takes away a lot of hassle and it basically boils down to two commands: One to generate the buildsystem (cmake itself is not a buildsystem, it just generates one) and then one to launch the build itself.
This is nativity at it's best but I don't plan to move away from GoCD anytime soon once I setup everything. If I have (or want to) migrate to a different CD system in the future most of the hassle will be setting the CD system itself up. The two Custom Commands (or whatever the "new" CD system will call them) are not really what is going to keep me busy.


Best regards,
~ Joel

Reply all
Reply to author
Forward
0 new messages