I am developing a Jenkins plugin in Ruby. It is assumed that you can configure each node that connects to the server so that an email address is sent to the specified address when the node loses its connection with the master. EmailNodeProperty adds a field for entering an email address:
When configuring node, a field appears with the name email , where you can enter an email address. I want this field to be checked when entering the address.
When you save the configuration, an EmailNodeProperty is created, from where (on the right) you can access the email address.
MyComputerListener offline is called when node loses its connection:
class MyComputerListener include Jenkins::Slaves::ComputerListener include Jenkins::Plugin::Proxy def online(computer, listener) end def offline(computer)
MyComputerListener finds an email address and sends an email.
Does anyone know if form validation is possible in Ruby? According to the Jenkins wiki , this is what should be implemented (FIELD is supposed to be exchanged for the field name, so I think it should be doCheckEmail ):
public FormValidation doCheckFIELD(@QueryParameter String value) { if(looksOk(value)) return FormValidation.ok(); else return FormValidation.error("There a problem here"); }
How do you do this in Ruby? Where should the method be implemented? In EmailNodeProperty or in MyComputerListener ? How do you handle QueryParameter? A value of @ would make this an intstance variable in Ruby. (What is a Queryparameter?)
Any help would be greatly appreciated!
/ Jonathan
ruby validation jruby jenkins jenkins-plugins
JonatanEkstedt
source share