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

  • Make Github push to a remote server when it receives updates
  • AWS CodePipeline, build failed & getting error as YAML_FILE_ERROR M
  • SSH into EC2 and can't execute git clone command
  • Elastic Beanstalk, Git and AWS Tools: How to clone repository to another workstation
  • chef deployment?
  • Can't push to repository on EC2 - Could not resolve hostname
  • 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

  • Couldn't find any revision to build. Verify the repository and branch configuration for this job. Finished: FAILURE
  • Jenkins path to git Windows master / Linux slave
  • Can't store sh command output through DSL (groovy) in Jenkins pipeline job
  • Jenkins Build Periodically - Schedule
  • Add SonarQube to jenkins job pipeline failed
  • Attempting to use scm:tag in a Jenkins job for a Git repository that requires a username/password
  • 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.