我需要使用Jenkins集成为管道编写CFT,以进行构建/测试。我发现这个documentation可以为詹金斯舞台设置ActionTypeId
。但是此文档未指定如何设置 jenkins服务器的server url
。而且,我不清楚在哪里提供 Jenkins提供商名称。是在ActionTypeId
还是configuration
属性中?
我在互联网上也找不到该用例的任何示例。
请提供使用AWS Cloudformation模板为AWS Codepipeline设置Jenkins Action Provider的正确示例。
以下是我从上述文档中学到的示例cft中的一部分。
"stages": [
{
"name": "Jenkins",
"actions": [
...
{
"name": "Jenkins Build",
"actionTypeId": {
"category": "Build",
"owner": "Custom",
"provider": "Jenkins",
"version": "1"
},
"runOrder": 2,
"configuration": {
???
},
...
}
]
},
...
]
答案 0 :(得分:0)
我缺少的一条信息是,我需要创建一个Custom Action才能使用Jenkins作为代码管道的Action提供程序。
首先,我添加了以下自定义操作:
JenkinsCustomActionType:
Type: AWS::CodePipeline::CustomActionType
Properties:
Category: Build
Provider: !Ref JenkinsProviderName
Version: 1
ConfigurationProperties:
-
Description: "The name of the build project must be provided when this action is added to the pipeline."
Key: true
Name: ProjectName
Queryable: false
Required: true
Secret: false
Type: String
InputArtifactDetails:
MaximumCount: 5
MinimumCount: 0
OutputArtifactDetails:
MaximumCount: 5
MinimumCount: 0
Settings:
EntityUrlTemplate: !Join ['', [!Ref JenkinsServerURL, "/job/{Config:ProjectName}/"]]
ExecutionUrlTemplate: !Join ['', [!Ref JenkinsServerURL, "/job/{Config:ProjectName}/{ExternalExecutionId}/"]]
Tags:
- Key: Name
Value: custom-jenkins-action-type
jenkins服务器URL在
settings
中提供了自定义操作 并且为Provider
指定了Jenkins提供程序名称。哪个是 我最初遇到的问题。
然后按以下方式配置管道阶段:
DevPipeline:
Type: AWS::CodePipeline::Pipeline
DependsOn: JenkinsCustomActionType
Properties:
Name: Dev-CodePipeline
RoleArn:
Fn::GetAtt: [ CodePipelineRole, Arn ]
Stages:
...
- Name: DevBuildVerificationTest
Actions:
- Name: JenkinsDevBVT
ActionTypeId:
Category: Build
Owner: Custom
Version: 1
Provider: !Ref JenkinsProviderName
Configuration:
ProjectName: !Ref JenkinsDevBVTProjectName
RunOrder: 4
必须在管道之前创建自定义操作。因此DependsOn: JenkinsCustomActionType