AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
搭CreateCustomActionType
配 AWS SDK或使用 CLI
下列程式碼範例會示範如何使用CreateCustomActionType
。
- CLI
-
- AWS CLI
-
建立自訂動作
此範例會建立自訂動作,以 AWS CodePipeline 使用包含自訂動作結構的已建立JSON檔案 (此處名為 MyCustomAction .json)。如需有關建立自訂動作 (包括檔案結構) 需求的詳細資訊,請參閱《 AWS CodePipeline 使用指南》。
aws codepipeline create-custom-action-type --cli-input-json
file://MyCustomAction.json
JSON檔案內容
MyCustomAction.json
:{ "category": "Build", "provider": "MyJenkinsProviderName", "version": "1", "settings": { "entityUrlTemplate": "https://192.0.2.4/job/{Config:ProjectName}/", "executionUrlTemplate": "https://192.0.2.4/job/{Config:ProjectName}/lastSuccessfulBuild/{ExternalExecutionId}/" }, "configurationProperties": [ { "name": "MyJenkinsExampleBuildProject", "required": true, "key": true, "secret": false, "queryable": false, "description": "The name of the build project must be provided when this action is added to the pipeline.", "type": "String" } ], "inputArtifactDetails": { "maximumCount": 1, "minimumCount": 0 }, "outputArtifactDetails": { "maximumCount": 1, "minimumCount": 0 } }
此指令會傳回自訂動作的結構。
-
如需詳API細資訊,請參閱AWS CLI 指令參考CreateCustomActionType
中的。
-
- PowerShell
-
- 適用的工具 PowerShell
-
範例 1:此範例會建立具有指定屬性的新自訂動作。
New-CPCustomActionType -Category Build -ConfigurationProperty @{"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"} -Settings_EntityUrlTemplate "https://my-build-instance/job/{Config:ProjectName}/" -Settings_ExecutionUrlTemplate "https://my-build-instance/job/mybuildjob/lastSuccessfulBuild{ExternalExecutionId}/" -InputArtifactDetails_MaximumCount 1 -OutputArtifactDetails_MaximumCount 1 -InputArtifactDetails_MinimumCount 0 -OutputArtifactDetails_MinimumCount 0 -Provider "MyBuildProviderName" -Version 1
輸出:
ActionConfigurationProperties : {ProjectName} Id : Amazon.CodePipeline.Model.ActionTypeId InputArtifactDetails : Amazon.CodePipeline.Model.ArtifactDetails OutputArtifactDetails : Amazon.CodePipeline.Model.ArtifactDetails Settings : Amazon.CodePipeline.Model.ActionTypeSettings
-
如需詳API細資訊,請參閱AWS Tools for PowerShell 指令程CreateCustomActionType式參考中的。
-
AcknowledgeJob
CreatePipeline