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

Error on using keychainPwd() with DSL groovy

    Details

    • Type: Bug
    • Status: In Progress (View Workflow)
    • Priority: Blocker
    • Resolution: Unresolved
    • Component/s: xcode-plugin
    • Environment:
      Jenkins 2.190.1 with xcode-plugin 2.0.12, job-dsl 1.76 and structs 1.20
    • Similar Issues:

      Description

      When defining the parameter keychainPwd() using groovy for describing a job using DSL, it seems with the new version cannot be done. 

      When using a string, job DSL processing shows this error:

      • Example: -->
      keychainPwd('password')

      Processing DSL script ios.groovy
      ERROR: (unknown source) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.keychainPwd() is applicable for argument types: (java.lang.String) values: [password]

      Prior to 2.0.12 keychainPwd used a String.

      • Example: -->

       

      def keychainPwdVar = hudson.util.Secret.fromString('password')
      
      keychainPwd(keychainPwdVar)
      

      Processing DSL script ios.groovy
      ERROR: (unknown source) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.keychainPwd() is applicable for argument types: (hudson.util.Secret) values: [password]

      In 2.0.12 keychainPwd could use a String (deprecated) or the newone Secret.

       

      I have tested all kind of possible combinations without luck. Not sure if I should define it in other way or this is a kind of bug when usind DSL.

        Attachments

          Activity

          Hide
          kazuhidet Kazuhide Takahashi added a comment -

          When unlocking a macOS keychain with Jenkins Xcode Plugin, keychainPwd is not a method, it is a parameter.
          If you want to write a process to unlock the keychain in your Groovy script, you would write:

          ...
          
          def keychainPwdVar = ""
          
          ...
          
          script {     
              keychainPwdVar = hudson.util.Secret.fromString('password')
          }
          unlockMacOSKeychain(keychainPath: "Path/To/Keychain", keychainPwd: keychainPwdVar)
          

          or

          ...
          
          def keychainPwdVar = ""
          
          ...
          
          script {     
              keychainPwdVar = hudson.util.Secret.fromString('password')
          }
          xcodeBuild(
              ...
              unlockKeychain: true,
              keychainPath: "Path/To/Keychain",
              keychainPwd: keychainPwdVar,
              ...
          )
          

          However, this method is not preferable because the password appears in the Groovy script, so it is recommended that you define a keychain password / pass pair as a credential and use it if possible.

          Show
          kazuhidet Kazuhide Takahashi added a comment - When unlocking a macOS keychain with Jenkins Xcode Plugin, keychainPwd is not a method, it is a parameter. If you want to write a process to unlock the keychain in your Groovy script, you would write: ... def keychainPwdVar = "" ... script {     keychainPwdVar = hudson.util.Secret.fromString( 'password' ) } unlockMacOSKeychain(keychainPath: "Path/To/Keychain" , keychainPwd: keychainPwdVar) or ... def keychainPwdVar = "" ... script {     keychainPwdVar = hudson.util.Secret.fromString( 'password' ) } xcodeBuild( ... unlockKeychain: true , keychainPath: "Path/To/Keychain" , keychainPwd: keychainPwdVar, ... ) However, this method is not preferable because the password appears in the Groovy script, so it is recommended that you define a keychain password / pass pair as a credential and use it if possible.
          Hide
          dtorres_vl Diego Torres added a comment - - edited

          Hi, thanks for your fast response. It seems problem comes when using job DSL from groovy, as the syntax you have used is different. I paste you a "complete" step from groovy script for job DSL description:

           

          steps { 
             keychainPwdVar = hudson.util.Secret.fromString('password')
          
             importDeveloperProfile { 
               profileId("jenkins-developerprofile") 
               developerProfileId("jenkins-developerprofile") 
               importIntoExistingKeychain(true) 
               keychainName("") 
               keychainPath('${HOME}/Library/Keychains/login.keychain') 
               keychainPwd(keychainPwdVar) 
             }
           
             xcodeBuild { 
               buildIpa(true) 
               generateArchive(true) 
               noConsoleLog(false) 
               logfileOutputDirectory('${WORKSPACE}/output') 
               cleanBeforeBuild(true) 
               cleanTestReports(true) 
               configuration("Release") 
               target("") 
               sdk("") 
               xcodeProjectPath("temp/project") 
               xcodeProjectFile("") 
               xcodebuildArguments("-showBuildTimingSummary") 
               cfBundleVersionValue("") 
               cfBundleShortVersionStringValue("") 
               unlockKeychain(true) 
               keychainName("") 
               keychainPath('${HOME}/Library/Keychains/login.keychain') 
               keychainPwd(keychainPwdVar) 
               symRoot("") 
               xcodeWorkspaceFile("workspace") 
               xcodeSchema("workspace") 
               buildDir("") 
               developmentTeamName("iOS TEAM") 
               developmentTeamID("0123456789") 
               allowFailingBuildResults(false) 
               ipaName("iOS") 
               provideApplicationVersion(false) 
               ipaOutputDirectory('${WORKSPACE}/output') 
               changeBundleID(false) 
               bundleID("") 
               bundleIDInfoPlistPath("") 
               interpretTargetAsRegEx(false) 
               ipaExportMethod('ad-hoc') 
               provisioningProfiles { 
                 provisioningProfile { 
                   provisioningProfileAppId("") 
                   provisioningProfileUUID("") 
                 } 
               } 
               xcodeName("") 
               uploadBitcode(false) 
               uploadSymbols(true) 
               compileBitcode(false) 
               thinning("<none>") 
               appURL('http://url-test.com') 
               displayImageURL('http://url-test.com') 
               fullSizeImageURL('http://url-test.com') 
               assetPackManifestURL("") 
             } 
          }

          Prior to 2.0.12, keychainPwd('password') was defined using a String but now the way of using hudson.util.Secret for job DSL groovy is failing. Could you check if this is working with job DSL plugin using groovy? If yes, please, could you give me an example using this syntax?

          Show
          dtorres_vl Diego Torres added a comment - - edited Hi, thanks for your fast response. It seems problem comes when using job DSL from groovy, as the syntax you have used is different. I paste you a "complete" step from groovy script for job DSL description:   steps { keychainPwdVar = hudson.util.Secret.fromString( 'password' ) importDeveloperProfile { profileId( "jenkins-developerprofile" ) developerProfileId( "jenkins-developerprofile" ) importIntoExistingKeychain( true ) keychainName("") keychainPath( '${HOME}/Library/Keychains/login.keychain' ) keychainPwd(keychainPwdVar) } xcodeBuild { buildIpa( true ) generateArchive( true ) noConsoleLog( false ) logfileOutputDirectory( '${WORKSPACE}/output' ) cleanBeforeBuild( true ) cleanTestReports( true ) configuration( "Release" ) target("") sdk("") xcodeProjectPath( "temp/project" ) xcodeProjectFile("") xcodebuildArguments( "-showBuildTimingSummary" ) cfBundleVersionValue("") cfBundleShortVersionStringValue("") unlockKeychain( true ) keychainName("") keychainPath( '${HOME}/Library/Keychains/login.keychain' ) keychainPwd(keychainPwdVar) symRoot("") xcodeWorkspaceFile( "workspace" ) xcodeSchema( "workspace" ) buildDir("") developmentTeamName( "iOS TEAM" ) developmentTeamID( "0123456789" ) allowFailingBuildResults( false ) ipaName( "iOS" ) provideApplicationVersion( false ) ipaOutputDirectory( '${WORKSPACE}/output' ) changeBundleID( false ) bundleID("") bundleIDInfoPlistPath("") interpretTargetAsRegEx( false ) ipaExportMethod( 'ad-hoc' ) provisioningProfiles { provisioningProfile { provisioningProfileAppId("") provisioningProfileUUID("") } } xcodeName("") uploadBitcode( false ) uploadSymbols( true ) compileBitcode( false ) thinning( "<none>" ) appURL( 'http: //url-test.com' ) displayImageURL( 'http: //url-test.com' ) fullSizeImageURL( 'http: //url-test.com' ) assetPackManifestURL("") } } Prior to 2.0.12, keychainPwd('password') was defined using a String but now the way of using hudson.util.Secret for job DSL groovy is failing. Could you check if this is working with job DSL plugin using groovy? If yes, please, could you give me an example using this syntax?
          Hide
          kazuhidet Kazuhide Takahashi added a comment -

          Unfortunately, the Job DSL plugin doesn't seem to be compatible with the encrypted parameter (hudson.util.Secret).
          Therefore, to unlock the keychain from the Job DSL plugin via Xcode Plugin, it seems that there is no choice but to define the keychain path and password pair in "Configure System" and specify it with keychainName.

          Show
          kazuhidet Kazuhide Takahashi added a comment - Unfortunately, the Job DSL plugin doesn't seem to be compatible with the encrypted parameter (hudson.util.Secret). Therefore, to unlock the keychain from the Job DSL plugin via Xcode Plugin, it seems that there is no choice but to define the keychain path and password pair in "Configure System" and specify it with keychainName.
          Hide
          dtorres_vl Diego Torres added a comment -

          Ok, thanks again for your response. I will modify it for using a keychain previously stored in Jenkins configuration. Maybe when Job DSL was compatible with encrypted parameters.

          I will comment you again if a problem comes up using this method.

          Show
          dtorres_vl Diego Torres added a comment - Ok, thanks again for your response. I will modify it for using a keychain previously stored in Jenkins configuration. Maybe when Job DSL was compatible with encrypted parameters. I will comment you again if a problem comes up using this method.

            People

            • Assignee:
              kazuhidet Kazuhide Takahashi
              Reporter:
              dtorres_vl Diego Torres
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: