Description of problem: We are using JenkinsPipelineBuildStrategy in a BuildConfig (as stated at https://docs.openshift.com/container-platform/3.10/dev_guide/builds/build_strategies.html#pipeline-strategy-options). When starting a pipeline build with some environment variables setting to empty string, the pipeline build fails with the following message found from the console output of the Jenkins pipeline build: java.lang.IllegalArgumentException: Null value not allowed as an environment variable: NAME This happens because the Jenkins Sync Plugin (shipped with OpenShift Optimized Jenkins master container image) mistakenly maps the empty environment variable in JenkinsPipelineBuildStrategy into an null value in the Jenkins build parameter. This can be fixed by replacing null values with empty strings. Version-Release number of selected component (if applicable): master How reproducible: Steps to Reproduce: 1. Create a BuildConfig on OpenShift with JenkinsPipelineBuildStrategy, define some environment variables with empty string: kind: "BuildConfig" apiVersion: "v1" metadata: name: "demo-pipeline" spec: strategy: jenkinsPipelineStrategy: env: - name: "NAME" value: "" jenkinsfile: |- pipeline { agent { kubernetes { cloud 'openshift' label "jenkins-slave-${UUID.randomUUID().toString()}" yaml """ apiVersion: v1 kind: Pod metadata: labels: app: "my-jenkins-slave" spec: containers: - name: jnlp image: docker.io/openshift/jenkins-slave-base-centos7:latest tty: true resources: requests: memory: 512Mi cpu: 200m limits: memory: 768Mi cpu: 500m """ } } stages { stage('foo') { steps { echo "Hello, ${env.NAME}" } } } } 2. start a build with `oc start-build demo-pipeline` or `oc start-build demo-pipeline -e NAME=` Actual results: You will get an error message from the Jenkins Console output like this: java.lang.IllegalArgumentException: Null value not allowed as an environment variable: NAME at hudson.EnvVars.put(EnvVars.java:359) at hudson.model.StringParameterValue.buildEnvironment(StringParameterValue.java:59) at hudson.model.ParametersAction.buildEnvironment(ParametersAction.java:145) at hudson.model.Run.getEnvironment(Run.java:2294) at org.jenkinsci.plugins.workflow.job.WorkflowRun.getEnvironment(WorkflowRun.java:513) at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerStepExecution.start(ContainerStepExecution.java:86) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:229) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:153) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20) at org.csanchez.jenkins.plugins.kubernetes.pipeline.KubernetesDeclarativeAgentScript.run(jar:file:/var/lib/jenkins/plugins/kubernetes/WEB-INF/lib/kubernetes.jar!/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgentScript.groovy:58) at org.jenkinsci.plugins.pipeline.modeldefinition.agent.CheckoutScript.checkoutAndRun(jar:file:/var/lib/jenkins/plugins/pipeline-model-extensions/WEB-INF/lib/pipeline-model-extensions.jar!/org/jenkinsci/plugins/pipeline/modeldefinition/agent/CheckoutScript.groovy:66) at org.jenkinsci.plugins.pipeline.modeldefinition.agent.CheckoutScript.doCheckout(jar:file:/var/lib/jenkins/plugins/pipeline-model-extensions/WEB-INF/lib/pipeline-model-extensions.jar!/org/jenkinsci/plugins/pipeline/modeldefinition/agent/CheckoutScript.groovy:42) at org.csanchez.jenkins.plugins.kubernetes.pipeline.KubernetesDeclarativeAgentScript.run(jar:file:/var/lib/jenkins/plugins/kubernetes/WEB-INF/lib/kubernetes.jar!/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgentScript.groovy:48) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82) at sun.reflect.GeneratedMethodAccessor302.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46) at com.cloudbees.groovy.cps.Next.step(Next.java:83) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163) at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$101(SandboxContinuable.java:34) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.lambda$run0$0(SandboxContinuable.java:59) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:58) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:332) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:83) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:244) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:232) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Finished: FAILURE Expected results: The pipeline build is successful. Additional info: Because this is easy to fix, I've open a PR for this issue https://github.com/openshift/jenkins-sync-plugin/pull/250
PR https://github.com/openshift/jenkins-sync-plugin/pull/250 is addressing this
OK, brew-pulp-docker01.web.prod.ext.phx2.redhat.com:8888/openshift3/jenkins-2-rhel7 v3.11.0.20180814.150701 27d969d77979 16 hours ago 1.39GB has v1.0.25 of the sync plugin. Ready for QE ....
Can't reproduce this bug with jenkins-2-rhel7:v3.11.0-0.17.0 which has installed v1.0.25 of the sync plugin.
Thanks for the rapid response. This issue is not fully fixed by PR#250, which only does the substitution before a job run is triggered by `oc start-build` or from Web UI. The fix should also be applied to the Jenkins job creation process, otherwise a job run triggered by timer or poll-scm will also fail with NullPointerException. Additional fix is provided by https://github.com/openshift/jenkins-sync-plugin/pull/256.
v1.0.27 has been initiated since the merging of https://github.com/openshift/jenkins-sync-plugin/pull/256 I'll defer to QA on the need to reverify where they include the poll-scm scenario once a brew-pulp image has v1.0.27.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2018:2652