Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-68885

maskPasswords step in Jenkinsfile fails

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • mask-passwords-plugin
    • None
    • Jenkins 2.346.1
      mask-passwords-plugin 3.3

      Recently upgraded and ran into a job that worked on mask-passwords 3.0, so went about testing what the syntax should be for the new plugin and generated this code from the pipeline Snippet Generator.

      Was the old format supposed to break without any deprecation warning (though TBF we skipped v3.1 of the plugin)?  And is there an issue with this snippet generated code / pipeline provided ?

      #!/usr/bin/env groovy
      pipeline {
          agent none
          options {
              buildDiscarder(logRotator(daysToKeepStr: '10', numToKeepStr: '10'))
          }
          stages {
              stage('Test Mask Passwords') {
                 agent { label('ubuntu') }
                 steps {
          		   maskPasswords(varMaskRegexes: [[name: 'thisWasGeneratedAsNull', value: [$class: 'VarMaskRegex', regex: 'Works']]], varPasswordPairs: [[password: 'asdf', var: 'asdf']]) {
                          sh '''#!/bin/bash -e
      					    echo "Passwords should not be shown in console output"
      					    echo "regex: Works"
      					    echo "pass: asdf"
                          '''.stripIndent()
                     }
                 }
              }
          }
      }
      

      And get this stack trace - both name null (the way snippet generated) or name string (a variation I tested) errored the same way.

      [2022-06-29T21:00:23.114Z] java.lang.ClassCastException: class java.util.Collections$UnmodifiableMap cannot be cast to class java.lang.String (java.util.Collections$UnmodifiableMap and java.lang.String are in module java.base of loader 'bootstrap')
      [2022-06-29T21:00:23.114Z] 	at com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsConfig$VarMaskRegexEntry$DescriptorImpl.customInstantiate(MaskPasswordsConfig.java:731)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:304)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:474)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerceList(DescribableModel.java:585)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:458)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:409)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:329)
      [2022-06-29T21:00:23.114Z] Caused: java.lang.IllegalArgumentException: Could not instantiate {varMaskRegexes=[{name=test, value={$class=VarMaskRegex, regex=Works}}], varPasswordPairs=[{password=asdf, var=asdf}]} for com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:334)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable.instantiate(UninstantiatedDescribable.java:208)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:466)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:409)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:329)
      [2022-06-29T21:00:23.114Z] Caused: java.lang.IllegalArgumentException: Could not instantiate {delegate=@maskPasswords(varMaskRegexes=[{name=test, value={$class=VarMaskRegex, regex=Works}}],varPasswordPairs=[{password=asdf, var=asdf}])} for org.jenkinsci.plugins.workflow.steps.CoreWrapperStep
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:334)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:305)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:502)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:199)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
      [2022-06-29T21:00:23.114Z] 	at jdk.internal.reflect.GeneratedMethodAccessor6039.invoke(Unknown Source)
      [2022-06-29T21:00:23.114Z] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      [2022-06-29T21:00:23.114Z] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      [2022-06-29T21:00:23.114Z] 	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
      [2022-06-29T21:00:23.114Z] 	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      [2022-06-29T21:00:23.114Z] 	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
      [2022-06-29T21:00:23.114Z] 	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
      [2022-06-29T21:00:23.114Z] 	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:41)
      [2022-06-29T21:00:23.114Z] 	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
      [2022-06-29T21:00:23.114Z] 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      [2022-06-29T21:00:23.114Z] 	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:163)
      [2022-06-29T21:00:23.114Z] 	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:158)
      [2022-06-29T21:00:23.114Z] 	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161)
      [2022-06-29T21:00:23.114Z] 	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
      [2022-06-29T21:00:23.114Z] 	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
      [2022-06-29T21:00:23.114Z] 	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
      [2022-06-29T21:00:23.114Z] Caused: java.lang.IllegalArgumentException: Failed to prepare maskPasswords step
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:504)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:199)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
      [2022-06-29T21:00:23.114Z] 	at jdk.internal.reflect.GeneratedMethodAccessor6039.invoke(Unknown Source)
      [2022-06-29T21:00:23.114Z] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      [2022-06-29T21:00:23.114Z] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      [2022-06-29T21:00:23.114Z] 	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
      [2022-06-29T21:00:23.114Z] 	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      [2022-06-29T21:00:23.114Z] 	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
      [2022-06-29T21:00:23.114Z] 	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
      [2022-06-29T21:00:23.114Z] 	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:41)
      [2022-06-29T21:00:23.114Z] 	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
      [2022-06-29T21:00:23.114Z] 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      [2022-06-29T21:00:23.114Z] 	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:163)
      [2022-06-29T21:00:23.114Z] 	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:158)
      [2022-06-29T21:00:23.114Z] 	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161)
      [2022-06-29T21:00:23.114Z] 	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
      [2022-06-29T21:00:23.114Z] 	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
      [2022-06-29T21:00:23.114Z] 	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
      [2022-06-29T21:00:23.114Z] 	at WorkflowScript.run(WorkflowScript:14)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.delegateAndExecute(ModelInterpreter.groovy:137)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.executeSingleStage(ModelInterpreter.groovy:666)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.catchRequiredContextForNode(ModelInterpreter.groovy:395)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.catchRequiredContextForNode(ModelInterpreter.groovy:393)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.executeSingleStage(ModelInterpreter.groovy:665)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:288)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.toolsBlock(ModelInterpreter.groovy:544)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.toolsBlock(ModelInterpreter.groovy:543)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:276)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:443)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:442)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:275)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withCredentialsBlock(ModelInterpreter.groovy:481)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withCredentialsBlock(ModelInterpreter.groovy:480)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:274)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inDeclarativeAgent(ModelInterpreter.groovy:595)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.pipeline.modeldefinition.agent.CheckoutScript.checkoutAndRun(CheckoutScript.groovy:61)
      [2022-06-29T21:00:23.114Z] 	at ___cps.transform___(Native Method)
      [2022-06-29T21:00:23.114Z] 	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
      [2022-06-29T21:00:23.114Z] 	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
      [2022-06-29T21:00:23.114Z] 	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
      [2022-06-29T21:00:23.114Z] 	at jdk.internal.reflect.GeneratedMethodAccessor234.invoke(Unknown Source)
      [2022-06-29T21:00:23.114Z] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      [2022-06-29T21:00:23.114Z] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      [2022-06-29T21:00:23.114Z] 	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      [2022-06-29T21:00:23.114Z] 	at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
      [2022-06-29T21:00:23.114Z] 	at com.cloudbees.groovy.cps.Next.step(Next.java:83)
      [2022-06-29T21:00:23.114Z] 	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
      [2022-06-29T21:00:23.114Z] 	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
      [2022-06-29T21:00:23.114Z] 	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136)
      [2022-06-29T21:00:23.114Z] 	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275)
      [2022-06-29T21:00:23.114Z] 	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:187)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:420)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:95)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:330)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:294)
      [2022-06-29T21:00:23.114Z] 	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
      [2022-06-29T21:00:23.114Z] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      [2022-06-29T21:00:23.114Z] 	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
      [2022-06-29T21:00:23.114Z] 	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      [2022-06-29T21:00:23.114Z] 	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
      [2022-06-29T21:00:23.114Z] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      [2022-06-29T21:00:23.114Z] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      [2022-06-29T21:00:23.114Z] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      [2022-06-29T21:00:23.114Z] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      [2022-06-29T21:00:23.114Z] 	at java.base/java.lang.Thread.run(Thread.java:829)
      

            Unassigned Unassigned
            diginc Adam BH
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: