使用Groovy配置Jenkins EC2-Plugin [英] Configure Jenkins EC2-Plugin with Groovy
问题描述
我试图通过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 = [a wsTemplate]
def ec2Cloud = new AmazonEC2Cloud(
'foo',
true,
'',
'us-west-2',
'',
'10',
slaveTemplates
)
def cloudList = Jenkins.instance.clouds
cloudList.add(ec2Cloud)
有什么想法?
这些是错误消息
错误:找不到匹配的构造函数:hudson.plugins.ec2.SlaveTemplate
或
错误:无法找到匹配的构造函数:hudson.plugins.ec2.AmazonEC2Cloud
您对 SlaveTemplate
的调用与任何构造函数都不匹配: https://github.com/jenkinsci/ec2-plugin/blob/master/src/main/java/hudson/plugins/ EC2 / SlaveTempla te.java
例如,第三个参数( spotConfig
)正在寻找一个 SpotConfiguration
对象。您目前在那里定义了一个空字符串。 (你可以用 null
来代替)。
另外,实例类型参数应该是 InstanceType
,不是一个字符串。为了解决这个问题,你需要在groovy脚本的顶部添加 import com.amazonaws.services.ec2.model.InstanceType
,并将 't2.micro'
with InstanceType.fromValue('t2.micro')
。
完整的示例,请参阅 https://gist.github.com/vrivellino/97954495938e38421ba4504049fd44ea
I am trying to configure the Jenkins EC2-Plugin via Groovy. Plugin code: https://github.com/jenkinsci/ec2-plugin
I'm trying to setup the cloud with a name to get started
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)
Any ideas?
These are the error messages
Error: Could not find matching constructor for: hudson.plugins.ec2.SlaveTemplate
or
Error: Could not find matching constructor for: hudson.plugins.ec2.AmazonEC2Cloud
Your call to SlaveTemplate
does not match any of the constructors: https://github.com/jenkinsci/ec2-plugin/blob/master/src/main/java/hudson/plugins/ec2/SlaveTemplate.java
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 com.amazonaws.services.ec2.model.InstanceType
to the top of the groovy script and replace 't2.micro'
with InstanceType.fromValue('t2.micro')
.
For a full example, see https://gist.github.com/vrivellino/97954495938e38421ba4504049fd44ea
这篇关于使用Groovy配置Jenkins EC2-Plugin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!