我正在使用Dockerfile构建Jenkins,在Docker构建期间,我希望Jenkins预先配置一组作业。我发现这适用于作业播种的乔布斯DSL,但我尚未预配置“管道”DSL。考虑到Jenkins的方向以及Jenkisfile,Pipeline等的使用,我认为必须有一些方法可以让Jenkins自动运行一组使用Pipeline方法构建的作业
示例管道:
pipeline {
agent {
label 'cft'
}
parameters {
string(name: 'StackName', defaultValue: 'cft-stack', description: 'The name to give the CFT stack.')
string(name: 'KeyName', defaultValue: 'ACCOUNT', description: 'The account key to use for encryption.')
string(name: 'VpcId', defaultValue: 'vpc-1234', description: 'The VPC to assign to the cluster resources.')
string(name: 'SubnetID', defaultValue: 'subnet-1234, subnet-6789', description: 'The subnet(s) to assign to the cluster resources.')
stages {
stage('Build') {
steps {
s3Download(file:'cft.yaml'
, bucket:'cft-resources'
, path:'cft.yaml'
, force:true)
cfnUpdate(stack:"${params.StackName}"
, file:"cft.yaml"
, params:[
"SnapshotId=${params.SnapshotId}",
"KeyName=${params.KeyName}",
"VpcId=${params.VpcId}"
]
, timeoutInMinutes: 20
)
}
}
}
post {
failure {
echo 'FAILURE'
cfnDelete(stack:"${params.StackName}")
}
}
}
Dockerfile:
COPY ./groovy/*.groovy /usr/share/jenkins/ref/init.groovy.d/
答案 0 :(得分:0)
Pipeline的Groovy文件与可以执行配置Jenkins的Groovy代码不同。您无法按照尝试的方式添加管道。
您的选择包括
Jenkinsfile
)