我正在尝试通过Groovy配置Jenkins EC2-Plugin。插件代码:https : //github.com/jenkinsci/ec2-plugin
我正在尝试使用一个名称来设置云以开始
import hudson.model.* import jenkins.model.* import hudson.plugins.ec2.* import com.amazonaws.services.ec2.model.* SlaveTemplate awsTemplate = new SlaveTemplate( 'ami-1234567', '', '', 'sg-1234567', 't2.micro', true, 'foo', '', 'stuff', 'run code', '/var/tmp', 'more code', '4', '', '', '', false, 'subnet-1234567', '', '60', false, '', 'iam-profile', false, false, '', false, '', true, false ) def slaveTemplates = [awsTemplate] def ec2Cloud = new AmazonEC2Cloud( 'foo', true, '', 'us-west-2', '', '10', slaveTemplates ) def cloudList = Jenkins.instance.clouds cloudList.add(ec2Cloud)
有任何想法吗?
这些是错误消息
Error: Could not find matching constructor for: hudson.plugins.ec2.SlaveTemplate
要么
Error: Could not find matching constructor for: hudson.plugins.ec2.AmazonEC2Cloud
您对的调用SlaveTemplate与任何构造函数都不匹配:https : //github.com/jenkinsci/ec2-plugin/blob/master/src/main/java/hudson/plugins/ec2/SlaveTemplate.java
SlaveTemplate
例如,第三个参数(spotConfig)正在寻找SpotConfiguration对象。您目前在此处定义了一个空字符串。(您可以将其替换为null。)
spotConfig
SpotConfiguration
null
另外,instance-type参数应该是InstanceType,而不是字符串。要更正此问题,您需要添加import com.amazonaws.services.ec2.model.InstanceType到groovy脚本的顶部并替换't2.micro'为InstanceType.fromValue('t2.micro')。
InstanceType
import com.amazonaws.services.ec2.model.InstanceType
't2.micro'
InstanceType.fromValue('t2.micro')
For a full example, see https://gist.github.com/vrivellino/97954495938e38421ba4504049fd44ea