-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
Jenkins 2.19.2
Quality Gates Plugin 2.5
It's not possible to use an environment variable as the project key. If you try to do it I, the following exception is shown when saving the project configuration:
javax.servlet.ServletException: quality.gates.jenkins.plugin.QGException: Environment variable with name 'ROJECT_KE' does not exist.
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:796)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:233)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:233)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135)
at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:206)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:132)
..........
This is very easy to fix - just delete the code related to checking whether that variable exists at job configuration saving time (as opposed to "at job exeuction time").
https://github.com/jenkinsci/quality-gates-plugin/blob/master/QualityGatesPlugin/src/main/java/quality/gates/jenkins/plugin/JobConfigurationService.java#L25
Note that you can generate jobs using job-dsl that have a variable as PROJECT_KEY and the jobs will work as expected - it's just that the project configuration can no longer be saved due to this exception.
Also note that the source code doesn't deal with variables correct in most of the cases - only the most simple case is considered (where PROJECT_KEY is exactly one variable). This does not strictly relate to this bug should be fixed nevertheless
https://github.com/jenkinsci/quality-gates-plugin/blob/master/QualityGatesPlugin/src/main/java/quality/gates/jenkins/plugin/JobConfigurationService.java#L70