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

NullPointerException in Android Signing Plugin when accessing credentials

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Component/s: android-signing-plugin
    • Labels:
      None
    • Environment:
      Windows 10 1803
      Jenkins 2.121.1
      Android Signing Plugin 2.2.5
      Credentials Plugin 2.1.17
    • Similar Issues:

      Description

      We followed the instructions on the github page and created certificate credentials that use a PKCS12 certificate and selected them in the plugin. The certificate was converted from a normal keystore file create by Visual Studio. Using the certicate manually works fine.

      The plugin thrown a NullPointerException when accessing the credentials:

      09:01:56 java.lang.NullPointerException
      09:01:56 	at org.jenkinsci.plugins.androidsigning.SigningComponents.fromCredentials(SigningComponents.java:22)
      09:01:56 	at org.jenkinsci.plugins.androidsigning.SignApksBuilder.perform(SignApksBuilder.java:294)
      09:01:56 	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
      09:01:56 	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      09:01:56 	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
      09:01:56 	at hudson.model.Build$BuildExecution.build(Build.java:206)
      09:01:56 	at hudson.model.Build$BuildExecution.doRun(Build.java:163)
      09:01:56 	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
      09:01:56 	at hudson.model.Run.execute(Run.java:1794)
      09:01:56 	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      09:01:56 	at hudson.model.ResourceController.execute(ResourceController.java:97)
      09:01:56 	at hudson.model.Executor.run(Executor.java:429)
      

      We have looked at the code and it looks like the problem is in SignApksBuilder.getKeystore. The method does not find any credentials and returns null which causes the exception in the next step.

        Attachments

          Activity

          Hide
          restjohn Robert St. John added a comment -

          Is it possible that your key store ID is not properly configured? The key store ID you configure for the Sign APKs step must match exactly the ID of the key store credential you installed with the Credentials plugin UI. Can you share your job definition, either by screenshot of the configuration UI or your PIpeline code?

          Show
          restjohn Robert St. John added a comment - Is it possible that your key store ID is not properly configured? The key store ID you configure for the Sign APKs step must match exactly the ID of the key store credential you installed with the Credentials plugin UI. Can you share your job definition, either by screenshot of the configuration UI or your PIpeline code?
          Hide
          x3ntrix Artur Lipinski added a comment -

          In the Sign APK step we have selected the ID we entered previously in the Credentials plugin. (see the attached screenshots)

          Show
          x3ntrix Artur Lipinski added a comment - In the Sign APK step we have selected the ID we entered previously in the Credentials plugin. (see the attached screenshots)
          Hide
          restjohn Robert St. John added a comment -

          Thank you for the screenshots. Can you try leaving the Key Alias field blank? Perhaps there is a bug in retrieving keys by a specific alias. I'll need to spend some time to test that, but in the mean time you might be able to work around your issue by omitting the alias.

          Show
          restjohn Robert St. John added a comment - Thank you for the screenshots. Can you try leaving the Key Alias field blank? Perhaps there is a bug in retrieving keys by a specific alias. I'll need to spend some time to test that, but in the mean time you might be able to work around your issue by omitting the alias.
          Hide
          x3ntrix Artur Lipinski added a comment -

          Leaving the Key Alias field blank did not help, but we found the problem. It looks like the import of the certificate did not work correctly. After searching for possible solutions we found a post that mentioned that the import of a certificate might/will fail when the password is not entered before. We did not get any errors during the first import, but to be sure we deleted the certificate and added it again. This time providing the password first. And it works now.

          Sorry to have bothered you.

           

          Show
          x3ntrix Artur Lipinski added a comment - Leaving the Key Alias field blank did not help, but we found the problem. It looks like the import of the certificate did not work correctly. After searching for possible solutions we found a post that mentioned that the import of a certificate might/will fail when the password is not entered before. We did not get any errors during the first import, but to be sure we deleted the certificate and added it again. This time providing the password first. And it works now. Sorry to have bothered you.  
          Hide
          restjohn Robert St. John added a comment - - edited

          It's no bother, and no apology is necessary. I'm glad you were able to get your build working. Do you have more details about what was wrong with your key store, and can you share the link to the post you mentioned? I'd like to make changes to the plugin to be able to handle the error more gracefully rather than generating an unexplained NullPointerException. Thanks for your responsiveness.

          Show
          restjohn Robert St. John added a comment - - edited It's no bother, and no apology is necessary. I'm glad you were able to get your build working. Do you have more details about what was wrong with your key store, and can you share the link to the post you mentioned? I'd like to make changes to the plugin to be able to handle the error more gracefully rather than generating an unexplained NullPointerException . Thanks for your responsiveness.
          Hide
          x3ntrix Artur Lipinski added a comment -

          The post was this one:

          https://www.detroitlabs.com/blog/2017/05/24/securely-signing-jenkins-android-builds/

          Once you have your “PKCS12” file, you can upload the certificate. Make sure to enter the password before uploading or the upload will report a failure. Now you are ready to use this certificate on any of your Android jobs.

          We are currently trying to reproduce the issue and will post the result later.

          Show
          x3ntrix Artur Lipinski added a comment - The post was this one: https://www.detroitlabs.com/blog/2017/05/24/securely-signing-jenkins-android-builds/ Once you have your “PKCS12” file, you can upload the certificate. Make sure to enter the password before uploading or the upload will report a failure. Now you are ready to use this certificate on any of your Android jobs. We are currently trying to reproduce the issue and will post the result later.
          Hide
          x3ntrix Artur Lipinski added a comment -

          We tried to reproduce the issue several times, but unfortunately without success. We have no idea what went wrong with the first certificate import.

          Show
          x3ntrix Artur Lipinski added a comment - We tried to reproduce the issue several times, but unfortunately without success. We have no idea what went wrong with the first certificate import.
          Hide
          restjohn Robert St. John added a comment -

          I appreciate you trying. Let me know if you run into any more issues.

          Show
          restjohn Robert St. John added a comment - I appreciate you trying. Let me know if you run into any more issues.

            People

            Assignee:
            restjohn Robert St. John
            Reporter:
            x3ntrix Artur Lipinski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: