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

Config as Code Nullpointer when instanceCapStr is not initialized

    Details

    • Similar Issues:
    • Released As:
      EC2 Plugin 1.44

      Description

      A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

      Nullpointer:

      java.lang.NullPointerException
      	at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
      	at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
      Caused: java.lang.reflect.InvocationTargetException
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
      Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
       Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
       Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
      	at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) 

      Minimum example to reproduce via Config as Code (uncomment the instanceCapStr and it will reload successfully):

      jenkins:
        clouds:
        - amazonEC2:
            cloudName: "TestCloud"
            #instanceCapStr: ""
            privateKey: ""
            region: "us-west-2"
            remoteFS: "c:\\jenkins"
            useInstanceProfileForCredentials: false
      

       

      I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
      /blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

      Might want to update the demo example as well if it helps clarify for any required fields. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example of a Windows slave with user_data.  That's unrelated to this request though.

       

      EDIT: I've just noticed that I'm also getting a nullpointer when I do not specify the remoteFS: "c:
      jenkins" via CasC as well.  I've updated the above example to include it.  I received the following exception right after winrm connects and the temp directory is created if it doesn't exist:

       java.lang.NullPointerException
      	at hudson.Util.isRelativePath(Util.java:557)
      	at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:642)
      	at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:432)
      	at hudson.plugins.ec2.win.EC2WindowsLauncher.launchScript(EC2WindowsLauncher.java:76)
      	at hudson.plugins.ec2.EC2ComputerLauncher.launch(EC2ComputerLauncher.java:48)
      	at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:294)
      	at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
      	at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
      	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)

        Attachments

          Issue Links

            Activity

            jremitz Jake Remitz created issue -
            jremitz Jake Remitz made changes -
            Field Original Value New Value
            Description A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

            Nullpointer:
            {code:java}
            java.lang.NullPointerException
            at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
            at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
            Caused: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
            Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
             Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
             Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) {code}
            Minimum example to reproduce via Config as Code:
            {code:java}
            jenkins:
              clouds:
              - amazonEC2:
                  cloudName: "TestCloud"
                  #instanceCapStr: ""
                  privateKey: ""
                  region: "us-west-2"
                  useInstanceProfileForCredentials: false
            {code}
             

            I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
            /blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

            Might want to update the demo example as well. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example with user_data.  That's unrelated to this request though.
            A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

            Nullpointer:
            {code:java}
            java.lang.NullPointerException
            at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
            at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
            Caused: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
            Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
             Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
             Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) {code}
            Minimum example to reproduce via Config as Code:
            {code:java}
            jenkins:
              clouds:
              - amazonEC2:
                  cloudName: "TestCloud"
                  #instanceCapStr: ""
                  privateKey: ""
                  region: "us-west-2"
                  useInstanceProfileForCredentials: false
            {code}
             

            I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
             /blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

            Might want to update the demo example as well if it helps clarify for any required fields. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example of a Windows slave with user_data.  That's unrelated to this request though.
            jremitz Jake Remitz made changes -
            Description A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

            Nullpointer:
            {code:java}
            java.lang.NullPointerException
            at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
            at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
            Caused: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
            Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
             Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
             Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) {code}
            Minimum example to reproduce via Config as Code:
            {code:java}
            jenkins:
              clouds:
              - amazonEC2:
                  cloudName: "TestCloud"
                  #instanceCapStr: ""
                  privateKey: ""
                  region: "us-west-2"
                  useInstanceProfileForCredentials: false
            {code}
             

            I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
             /blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

            Might want to update the demo example as well if it helps clarify for any required fields. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example of a Windows slave with user_data.  That's unrelated to this request though.
            A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

            Nullpointer:
            {code:java}
            java.lang.NullPointerException
            at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
            at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
            Caused: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
            Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
             Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
             Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) {code}
            Minimum example to reproduce via Config as Code (uncomment the instanceCapStr and it will reload successfully):
            {code:java}
            jenkins:
              clouds:
              - amazonEC2:
                  cloudName: "TestCloud"
                  #instanceCapStr: ""
                  privateKey: ""
                  region: "us-west-2"
                  useInstanceProfileForCredentials: false
            {code}
             

            I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
             /blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

            Might want to update the demo example as well if it helps clarify for any required fields. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example of a Windows slave with user_data.  That's unrelated to this request though.
            jremitz Jake Remitz made changes -
            Description A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

            Nullpointer:
            {code:java}
            java.lang.NullPointerException
            at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
            at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
            Caused: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
            Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
             Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
             Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) {code}
            Minimum example to reproduce via Config as Code (uncomment the instanceCapStr and it will reload successfully):
            {code:java}
            jenkins:
              clouds:
              - amazonEC2:
                  cloudName: "TestCloud"
                  #instanceCapStr: ""
                  privateKey: ""
                  region: "us-west-2"
                  useInstanceProfileForCredentials: false
            {code}
             

            I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
             /blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

            Might want to update the demo example as well if it helps clarify for any required fields. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example of a Windows slave with user_data.  That's unrelated to this request though.
            A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

            Nullpointer:
            {code:java}
            java.lang.NullPointerException
            at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
            at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
            Caused: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
            Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
             Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
             Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) {code}
            Minimum example to reproduce via Config as Code (uncomment the instanceCapStr and it will reload successfully):
            {code:java}
            jenkins:
              clouds:
              - amazonEC2:
                  cloudName: "TestCloud"
                  #instanceCapStr: ""
                  privateKey: ""
                  region: "us-west-2"
                  remoteFS: "c:\\jenkins"
                  useInstanceProfileForCredentials: false
            {code}
             

            I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
             /blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

            Might want to update the demo example as well if it helps clarify for any required fields. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example of a Windows slave with user_data.  That's unrelated to this request though.

             

            *EDIT*: I've just noticed that I'm also getting a nullpointer when I do not specify the {{remoteFS: "c:\\jenkins"}} via CasC as well.  I've updated the above example to include it.  I received the following exception:
            {code:java}
             java.lang.NullPointerException
            at hudson.Util.isRelativePath(Util.java:557)
            at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:642)
            at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:432)
            at hudson.plugins.ec2.win.EC2WindowsLauncher.launchScript(EC2WindowsLauncher.java:76)
            at hudson.plugins.ec2.EC2ComputerLauncher.launch(EC2ComputerLauncher.java:48)
            at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:294)
            at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
            at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
            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){code}
            jremitz Jake Remitz made changes -
            Description A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

            Nullpointer:
            {code:java}
            java.lang.NullPointerException
            at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
            at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
            Caused: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
            Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
             Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
             Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) {code}
            Minimum example to reproduce via Config as Code (uncomment the instanceCapStr and it will reload successfully):
            {code:java}
            jenkins:
              clouds:
              - amazonEC2:
                  cloudName: "TestCloud"
                  #instanceCapStr: ""
                  privateKey: ""
                  region: "us-west-2"
                  remoteFS: "c:\\jenkins"
                  useInstanceProfileForCredentials: false
            {code}
             

            I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
             /blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

            Might want to update the demo example as well if it helps clarify for any required fields. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example of a Windows slave with user_data.  That's unrelated to this request though.

             

            *EDIT*: I've just noticed that I'm also getting a nullpointer when I do not specify the {{remoteFS: "c:\\jenkins"}} via CasC as well.  I've updated the above example to include it.  I received the following exception:
            {code:java}
             java.lang.NullPointerException
            at hudson.Util.isRelativePath(Util.java:557)
            at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:642)
            at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:432)
            at hudson.plugins.ec2.win.EC2WindowsLauncher.launchScript(EC2WindowsLauncher.java:76)
            at hudson.plugins.ec2.EC2ComputerLauncher.launch(EC2ComputerLauncher.java:48)
            at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:294)
            at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
            at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
            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){code}
            A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

            Nullpointer:
            {code:java}
            java.lang.NullPointerException
            at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
            at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
            Caused: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
            Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
             Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
             Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
            at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) {code}
            Minimum example to reproduce via Config as Code (uncomment the instanceCapStr and it will reload successfully):
            {code:java}
            jenkins:
              clouds:
              - amazonEC2:
                  cloudName: "TestCloud"
                  #instanceCapStr: ""
                  privateKey: ""
                  region: "us-west-2"
                  remoteFS: "c:\\jenkins"
                  useInstanceProfileForCredentials: false
            {code}
             

            I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
             /blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

            Might want to update the demo example as well if it helps clarify for any required fields. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example of a Windows slave with user_data.  That's unrelated to this request though.

             

            *EDIT*: I've just noticed that I'm also getting a nullpointer when I do not specify the {{remoteFS: "c:}}
            {{jenkins"}} via CasC as well.  I've updated the above example to include it.  I received the following exception right after winrm connects and the temp directory is created if it doesn't exist:
            {code:java}
             java.lang.NullPointerException
            at hudson.Util.isRelativePath(Util.java:557)
            at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:642)
            at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:432)
            at hudson.plugins.ec2.win.EC2WindowsLauncher.launchScript(EC2WindowsLauncher.java:76)
            at hudson.plugins.ec2.EC2ComputerLauncher.launch(EC2ComputerLauncher.java:48)
            at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:294)
            at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
            at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
            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){code}
            jremitz Jake Remitz made changes -
            Labels ec2-plugin configuration-as-code ec2-plugin
            oleg_nenashev Oleg Nenashev made changes -
            Labels configuration-as-code ec2-plugin configuration-as-code ec2-plugin jcasc-compatibility
            oleg_nenashev Oleg Nenashev made changes -
            Link This issue is duplicated by JENKINS-57562 [ JENKINS-57562 ]
            Hide
            timja Tim Jacomb added a comment -

            I believe fixed in https://github.com/jenkinsci/ec2-plugin/pull/358

            although unreleased

            Show
            timja Tim Jacomb added a comment - I believe fixed in  https://github.com/jenkinsci/ec2-plugin/pull/358 although unreleased
            timja Tim Jacomb made changes -
            Status Open [ 1 ] Fixed but Unreleased [ 10203 ]
            Resolution Fixed [ 1 ]
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            It was released in EC2 Plugin 1.44

            Show
            oleg_nenashev Oleg Nenashev added a comment - It was released in EC2 Plugin 1.44
            oleg_nenashev Oleg Nenashev made changes -
            Status Fixed but Unreleased [ 10203 ] Resolved [ 5 ]
            Released As EC2 Plugin 1.44

              People

              • Assignee:
                thoulen FABRIZIO MANFREDI
                Reporter:
                jremitz Jake Remitz
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: