Configure Jenkins EC2-Plugin with Groovy

I am trying to configure the Jenkins EC2-Plugin via Groovy.
Plugin code:

I’m trying to setup the cloud with a name to get started

  • git push origin master: permission denied (public key) error
  • Pushing to multiple EC2 instances on a load balancer
  • jenkins not able to connect to a repository
  • Correct Path for Git Remote Add from Amazon EC2 Instance to OSX Client Machine
  • Deploy a GitHub branch automatically to AWS Elastic Beanstalk
  • How to configure git in ec2 with my local machine?
  • import hudson.model.*
    import jenkins.model.*
    import hudson.plugins.ec2.*
    SlaveTemplate awsTemplate = new SlaveTemplate(
      'run code',
      'more code',
    def slaveTemplates = [awsTemplate]
    def ec2Cloud = new AmazonEC2Cloud(
    def cloudList = Jenkins.instance.clouds

    Any ideas?

    These are the error messages

    Error: Could not find matching constructor for: hudson.plugins.ec2.SlaveTemplate


    Error: Could not find matching constructor for: hudson.plugins.ec2.AmazonEC2Cloud

  • How to get the current session user in Jenkins on a Groovy parameter
  • Jenkins JUnit Attachments Plugin throws 404 for attached files
  • Hosted Continuous Integration for PHP?
  • API support for manual approval of promoted builds in Jenkins?
  • Configure a hudson maven job to keep building if there are test failures, but only deploy if there are no test failures
  • ChromeDriver keeps crashing on Jenkins Selenium Job: “WebDriverError: Chrome failed to start: crashed”
  • 2 Solutions collect form web for “Configure Jenkins EC2-Plugin with Groovy”

    Your call to SlaveTemplate does not match any of the constructors:

    For example, the third parameter (spotConfig) is looking for a SpotConfiguration object. You currently have an empty string defined there. (You can replace that with null.)

    Also, the instance-type parameter should be an InstanceType, not a string. To correct that, you’ll want to add import to the top of the groovy script and replace 't2.micro' with InstanceType.fromValue('t2.micro').

    For a full example, see

    For starters, the only constructor available for this class has the following signature:

    public AmazonEC2Cloud(
      String cloudName, 
      boolean useInstanceProfileForCredentials, 
      String credentialsId, 
      String region, 
      String privateKey, 
      String instanceCapStr, 
      List<? extends SlaveTemplate> templates
    Git Baby is a git and github fan, let's start git clone.