When generating a "Hello World" plugin using the maven archetypes the CLI generates broken code. On a line 60 an undeclared symbol is referenced, `Messages` (also on line 62, 64 and 76). Combined with the lack of useful documentation around Jenkins and its ecosystem this lead to a lot of wasted time for me the other day.
When generating a "Hello World" plugin using the maven archetypes the CLI generates broken code. On a[ line 60|#L60] an undeclared symbol is referenced, `Messages` (also on line 62, 64 and 76). Combined with the lack of useful documentation around Jenkins and its ecosystem this lead to a lot of wasted time for me the other day.
Corrected code: {code:java} @Extension
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
public FormValidation doCheckName(@QueryParameter String value, @QueryParameter boolean useFrench) throws IOException, ServletException { ResourceBundle messages = ResourceBundle.getBundle("HelloWorldBuilder.Messages"); if (value.length() == 0) return FormValidation.error(messages.getString("HelloWorldBuilder.DescriptorImpl.errors.missingName")); if (value.length() < 4) return FormValidation.warning(messages.getString("HelloWorldBuilder.DescriptorImpl.warnings.tooShort")); if (!useFrench && value.matches(".*[éáàç].*")) { return FormValidation.warning(messages.getString("HelloWorldBuilder.DescriptorImpl.warnings.reallyFrench")); } return FormValidation.ok(); }