使用 Tools forCodePipeline 的 PowerShell 範例 - AWS SDK 程式碼範例

文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的 GitHub 範例。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 Tools forCodePipeline 的 PowerShell 範例

下列程式碼範例示範如何使用 AWS Tools for PowerShell with CodePipeline 來執行動作和實作常見案例。

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會示範如何呼叫個別服務函數,但您可以在相關案例中查看內容中的動作。

每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

下列程式碼範例示範如何使用 Confirm-CPJob

for PowerShell 工具

範例 1:此範例會取得指定任務的狀態。

Confirm-CPJob -JobId f570dc12-5ef3-44bc-945a-6e133EXAMPLE -Nonce 3

輸出:

Value ----- InProgress
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 AcknowledgeJob

下列程式碼範例示範如何使用 Disable-CPStageTransition

for PowerShell 工具

範例 1:此範例會停用指定管道中指定階段的傳入轉換。

Disable-CPStageTransition -PipelineName CodePipelineDemo -Reason "Disabling temporarily." -StageName Beta -TransitionType Inbound

下列程式碼範例示範如何使用 Enable-CPStageTransition

for PowerShell 工具

範例 1:此範例會啟用指定管道中指定階段的傳入轉換。

Enable-CPStageTransition -PipelineName CodePipelineDemo -StageName Beta -TransitionType Inbound
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 EnableStageTransition

下列程式碼範例示範如何使用 Get-CPActionType

for PowerShell 工具

範例 1:此範例會取得指定擁有者所有可用動作的相關資訊。

ForEach ($actionType in (Get-CPActionType -ActionOwnerFilter AWS)) { Write-Output ("For Category = " + $actionType.Id.Category + ", Owner = " + $actionType.Id.Owner + ", Provider = " + $actionType.Id.Provider + ", Version = " + $actionType.Id.Version + ":") Write-Output (" ActionConfigurationProperties:") ForEach ($acp in $actionType.ActionConfigurationProperties) { Write-Output (" For " + $acp.Name + ":") Write-Output (" Description = " + $acp.Description) Write-Output (" Key = " + $acp.Key) Write-Output (" Queryable = " + $acp.Queryable) Write-Output (" Required = " + $acp.Required) Write-Output (" Secret = " + $acp.Secret) } Write-Output (" InputArtifactDetails:") Write-Output (" MaximumCount = " + $actionType.InputArtifactDetails.MaximumCount) Write-Output (" MinimumCount = " + $actionType.InputArtifactDetails.MinimumCount) Write-Output (" OutputArtifactDetails:") Write-Output (" MaximumCount = " + $actionType.OutputArtifactDetails.MaximumCount) Write-Output (" MinimumCount = " + $actionType.OutputArtifactDetails.MinimumCount) Write-Output (" Settings:") Write-Output (" EntityUrlTemplate = " + $actionType.Settings.EntityUrlTemplate) Write-Output (" ExecutionUrlTemplate = " + $actionType.Settings.ExecutionUrlTemplate) }

輸出:

For Category = Deploy, Owner = AWS, Provider = ElasticBeanstalk, Version = 1: ActionConfigurationProperties: For ApplicationName: Description = The AWS Elastic Beanstalk Application name Key = True Queryable = False Required = True Secret = False For EnvironmentName: Description = The AWS Elastic Beanstalk Environment name Key = True Queryable = False Required = True Secret = False InputArtifactDetails: MaximumCount = 1 MinimumCount = 1 OutputArtifactDetails: MaximumCount = 0 MinimumCount = 0 Settings: EntityUrlTemplate = https://console.aws.amazon.com/elasticbeanstalk/r/application/{Config:ApplicationName} ExecutionUrlTemplate = https://console.aws.amazon.com/elasticbeanstalk/r/application/{Config:ApplicationName} For Category = Deploy, Owner = AWS, Provider = CodeDeploy, Version = 1: ActionConfigurationProperties: For ApplicationName: Description = The AWS CodeDeploy Application name Key = True Queryable = False Required = True Secret = False For DeploymentGroupName: Description = The AWS CodeDeploy Deployment Group name Key = True Queryable = False Required = True Secret = False InputArtifactDetails: MaximumCount = 1 MinimumCount = 1 OutputArtifactDetails: MaximumCount = 0 MinimumCount = 0 Settings: EntityUrlTemplate = https://console.aws.amazon.com/codedeploy/home?#/applications/{Config:ApplicationName}/deployment-groups/{Config:DeploymentGroupName} ExecutionUrlTemplate = https://console.aws.amazon.com/codedeploy/home?#/deployments/{ExternalExecutionId}
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 ListActionTypes

下列程式碼範例示範如何使用 Get-CPActionableJobList

for PowerShell 工具

範例 1:此範例會取得指定動作類別、擁有者、提供者、版本和查詢參數之所有可操作任務的相關資訊。

Get-CPActionableJobList -ActionTypeId_Category Build -ActionTypeId_Owner Custom -ActionTypeId_Provider MyCustomProviderName -ActionTypeId_Version 1 -QueryParam @{"ProjectName" = "MyProjectName"}

輸出:

AccountId Data Id Nonce --------- ---- -- ----- 80398EXAMPLE Amazon.CodePipeline.Model.JobData 0de392f5-712d-4f41-ace3-f57a0EXAMPLE 3
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 PollForJobs

下列程式碼範例示範如何使用 Get-CPJobDetail

for PowerShell 工具

範例 1:此範例會取得指定任務的一般資訊。

Get-CPJobDetail -JobId f570dc12-5ef3-44bc-945a-6e133EXAMPLE

輸出:

AccountId Data Id --------- ---- -- 80398EXAMPLE Amazon.CodePipeline.Model.JobData f570dc12-5ef3-44bc-945a-6e133EXAMPLE

範例 2:此範例會取得指定任務的詳細資訊。

$jobDetails = Get-CPJobDetail -JobId f570dc12-5ef3-44bc-945a-6e133EXAMPLE Write-Output ("For Job " + $jobDetails.Id + ":") Write-Output (" AccountId = " + $jobDetails.AccountId) $jobData = $jobDetails.Data Write-Output (" Configuration:") ForEach ($key in $jobData.ActionConfiguration.Keys) { $value = $jobData.ActionConfiguration.$key Write-Output (" " + $key + " = " + $value) } Write-Output (" ActionTypeId:") Write-Output (" Category = " + $jobData.ActionTypeId.Category) Write-Output (" Owner = " + $jobData.ActionTypeId.Owner) Write-Output (" Provider = " + $jobData.ActionTypeId.Provider) Write-Output (" Version = " + $jobData.ActionTypeId.Version) Write-Output (" ArtifactCredentials:") Write-Output (" AccessKeyId = " + $jobData.ArtifactCredentials.AccessKeyId) Write-Output (" SecretAccessKey = " + $jobData.ArtifactCredentials.SecretAccessKey) Write-Output (" SessionToken = " + $jobData.ArtifactCredentials.SessionToken) Write-Output (" InputArtifacts:") ForEach ($ia in $jobData.InputArtifacts) { Write-Output (" " + $ia.Name) } Write-Output (" OutputArtifacts:") ForEach ($oa in $jobData.OutputArtifacts) { Write-Output (" " + $oa.Name) } Write-Output (" PipelineContext:") $context = $jobData.PipelineContext Write-Output (" Name = " + $context.Action.Name) Write-Output (" PipelineName = " + $context.PipelineName) Write-Output (" Stage = " + $context.Stage.Name)

輸出:

For Job f570dc12-5ef3-44bc-945a-6e133EXAMPLE: AccountId = 80398EXAMPLE Configuration: ActionTypeId: Category = Build Owner = Custom Provider = MyCustomProviderName Version = 1 ArtifactCredentials: AccessKeyId = ASIAIEI3...IXI6YREX SecretAccessKey = cqAFDhEi...RdQyfa2u SessionToken = AQoDYXdz...5u+lsAU= InputArtifacts: MyApp OutputArtifacts: MyAppBuild PipelineContext: Name = Build PipelineName = CodePipelineDemo Stage = Build
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 GetJobDetails

下列程式碼範例示範如何使用 Get-CPPipeline

for PowerShell 工具

範例 1:此範例會取得指定管道的一般資訊。

Get-CPPipeline -Name CodePipelineDemo -Version 1

輸出:

ArtifactStore : Amazon.CodePipeline.Model.ArtifactStore Name : CodePipelineDemo RoleArn : arn:aws:iam::80398EXAMPLE:role/CodePipelineServiceRole Stages : {Source, Build, Beta, TestStage} Version : 1

範例 2:此範例會取得指定管道的詳細資訊。

$pipeline = Get-CPPipeline -Name CodePipelineDemo Write-Output ("Name = " + $pipeline.Name) Write-Output ("RoleArn = " + $pipeline.RoleArn) Write-Output ("Version = " + $pipeline.Version) Write-Output ("ArtifactStore:") Write-Output (" Location = " + $pipeline.ArtifactStore.Location) Write-Output (" Type = " + $pipeline.ArtifactStore.Type.Value) Write-Output ("Stages:") ForEach ($stage in $pipeline.Stages) { Write-Output (" Name = " + $stage.Name) Write-Output (" Actions:") ForEach ($action in $stage.Actions) { Write-Output (" Name = " + $action.Name) Write-Output (" Category = " + $action.ActionTypeId.Category) Write-Output (" Owner = " + $action.ActionTypeId.Owner) Write-Output (" Provider = " + $action.ActionTypeId.Provider) Write-Output (" Version = " + $action.ActionTypeId.Version) Write-Output (" Configuration:") ForEach ($key in $action.Configuration.Keys) { $value = $action.Configuration.$key Write-Output (" " + $key + " = " + $value) } Write-Output (" InputArtifacts:") ForEach ($ia in $action.InputArtifacts) { Write-Output (" " + $ia.Name) } ForEach ($oa in $action.OutputArtifacts) { Write-Output (" " + $oa.Name) } Write-Output (" RunOrder = " + $action.RunOrder) } }

輸出:

Name = CodePipelineDemo RoleArn = arn:aws:iam::80398EXAMPLE:role/CodePipelineServiceRole Version = 3 ArtifactStore: Location = MyBucketName Type = S3 Stages: Name = Source Actions: Name = Source Category = Source Owner = ThirdParty Provider = GitHub Version = 1 Configuration: Branch = master OAuthToken = **** Owner = my-user-name Repo = MyRepoName InputArtifacts: MyApp RunOrder = 1 Name = Build Actions: Name = Build Category = Build Owner = Custom Provider = MyCustomProviderName Version = 1 Configuration: ProjectName = MyProjectName InputArtifacts: MyApp MyAppBuild RunOrder = 1 Name = Beta Actions: Name = CodePipelineDemoFleet Category = Deploy Owner = AWS Provider = CodeDeploy Version = 1 Configuration: ApplicationName = CodePipelineDemoApplication DeploymentGroupName = CodePipelineDemoFleet InputArtifacts: MyAppBuild RunOrder = 1 Name = TestStage Actions: Name = MyJenkinsTestAction Category = Test Owner = Custom Provider = MyCustomTestProvider Version = 1 Configuration: ProjectName = MyJenkinsProjectName InputArtifacts: MyAppBuild RunOrder = 1
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 GetPipeline

下列程式碼範例示範如何使用 Get-CPPipelineList

for PowerShell 工具

範例 1:此範例會取得可用管道的清單。

Get-CPPipelineList

輸出:

Created Name Updated Version ------- ---- ------- ------- 8/13/2015 10:17:54 PM CodePipelineDemo 8/13/2015 10:17:54 PM 3 7/8/2015 2:41:53 AM MyFirstPipeline 7/22/2015 9:06:37 PM 7
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 ListPipelines

下列程式碼範例示範如何使用 Get-CPPipelineState

for PowerShell 工具

範例 1:此範例會取得指定管道階段的一般資訊。

Get-CPPipelineState -Name CodePipelineDemo

輸出:

Created : 8/13/2015 10:17:54 PM PipelineName : CodePipelineDemo PipelineVersion : 1 StageStates : {Source, Build, Beta, TestStage} Updated : 8/13/2015 10:17:54 PM

範例 2:此範例會取得指定管道狀態的詳細資訊。

ForEach ($stageState in (Get-CPPipelineState -Name $arg).StageStates) { Write-Output ("For " + $stageState.StageName + ":") Write-Output (" InboundTransitionState:") Write-Output (" DisabledReason = " + $stageState.InboundTransitionState.DisabledReason) Write-Output (" Enabled = " + $stageState.InboundTransitionState.Enabled) Write-Output (" LastChangedAt = " + $stageState.InboundTransitionState.LastChangedAt) Write-Output (" LastChangedBy = " + $stageState.InboundTransitionState.LastChangedBy) Write-Output (" ActionStates:") ForEach ($actionState in $stageState.ActionStates) { Write-Output (" For " + $actionState.ActionName + ":") Write-Output (" CurrentRevision:") Write-Output (" Created = " + $actionState.CurrentRevision.Created) Write-Output (" RevisionChangeId = " + $actionState.CurrentRevision.RevisionChangeId) Write-Output (" RevisionId = " + $actionState.CurrentRevision.RevisionId) Write-Output (" EntityUrl = " + $actionState.EntityUrl) Write-Output (" LatestExecution:") Write-Output (" ErrorDetails:") Write-Output (" Code = " + $actionState.LatestExecution.ErrorDetails.Code) Write-Output (" Message = " + $actionState.LatestExecution.ErrorDetails.Message) Write-Output (" ExternalExecutionId = " + $actionState.LatestExecution.ExternalExecutionId) Write-Output (" ExternalExecutionUrl = " + $actionState.LatestExecution.ExternalExecutionUrl) Write-Output (" LastStatusChange = " + $actionState.LatestExecution.LastStatusChange) Write-Output (" PercentComplete = " + $actionState.LatestExecution.PercentComplete) Write-Output (" Status = " + $actionState.LatestExecution.Status) Write-Output (" Summary = " + $actionState.LatestExecution.Summary) Write-Output (" RevisionUrl = " + $actionState.RevisionUrl) } }

輸出:

For Source: InboundTransitionState: DisabledReason = Enabled = LastChangedAt = LastChangedBy = ActionStates: For Source: CurrentRevision: Created = RevisionChangeId = RevisionId = EntityUrl = https://github.com/my-user-name/MyRepoName/tree/master LatestExecution: ErrorDetails: Code = Message = ExternalExecutionId = ExternalExecutionUrl = LastStatusChange = 07/20/2015 23:28:45 PercentComplete = 0 Status = Succeeded Summary = RevisionUrl = For Build: InboundTransitionState: DisabledReason = Enabled = True LastChangedAt = 01/01/0001 00:00:00 LastChangedBy = ActionStates: For Build: CurrentRevision: Created = RevisionChangeId = RevisionId = EntityUrl = http://54.174.131.1EX/job/MyJenkinsDemo LatestExecution: ErrorDetails: Code = TimeoutError Message = The action failed because a job worker exceeded its time limit. If this is a custom action, make sure that the job worker is configured correctly. ExternalExecutionId = ExternalExecutionUrl = LastStatusChange = 07/21/2015 00:29:29 PercentComplete = 0 Status = Failed Summary = RevisionUrl = For Beta: InboundTransitionState: DisabledReason = Enabled = True LastChangedAt = 01/01/0001 00:00:00 LastChangedBy = ActionStates: For CodePipelineDemoFleet: CurrentRevision: Created = RevisionChangeId = RevisionId = EntityUrl = https://console.aws.amazon.com/codedeploy/home?#/applications/CodePipelineDemoApplication/deployment-groups/CodePipelineDemoFleet LatestExecution: ErrorDetails: Code = Message = ExternalExecutionId = d-D5LTCZXEX ExternalExecutionUrl = https://console.aws.amazon.com/codedeploy/home?#/deployments/d-D5LTCZXEX LastStatusChange = 07/08/2015 22:07:42 PercentComplete = 0 Status = Succeeded Summary = Deployment Succeeded RevisionUrl = For TestStage: InboundTransitionState: DisabledReason = Enabled = True LastChangedAt = 01/01/0001 00:00:00 LastChangedBy = ActionStates: For MyJenkinsTestAction25: CurrentRevision: Created = RevisionChangeId = RevisionId = EntityUrl = http://54.174.131.1EX/job/MyJenkinsDemo LatestExecution: ErrorDetails: Code = Message = ExternalExecutionId = 5 ExternalExecutionUrl = http://54.174.131.1EX/job/MyJenkinsDemo/5 LastStatusChange = 07/08/2015 22:09:03 PercentComplete = 0 Status = Succeeded Summary = Finished RevisionUrl =
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 GetPipelineState

下列程式碼範例示範如何使用 New-CPCustomActionType

for 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

下列程式碼範例示範如何使用 New-CPPipeline

for PowerShell 工具

範例 1:此範例會建立具有指定設定的新管道。

$pipeline = New-Object Amazon.CodePipeline.Model.PipelineDeclaration $sourceStageAction = New-Object Amazon.CodePipeline.Model.ActionDeclaration $deployStageAction = New-Object Amazon.CodePipeline.Model.ActionDeclaration $sourceStageActionOutputArtifact = New-Object Amazon.CodePipeline.Model.OutputArtifact $sourceStageActionOutputArtifact.Name = "MyApp" $sourceStageAction.ActionTypeId = @{"Category" = "Source"; "Owner" = "AWS"; "Provider" = "S3"; "Version" = 1} $sourceStageAction.Configuration.Add("S3Bucket", "amzn-s3-demo-bucket") $sourceStageAction.Configuration.Add("S3ObjectKey", "my-object-key-name.zip") $sourceStageAction.OutputArtifacts.Add($sourceStageActionOutputArtifact) $sourceStageAction.Name = "Source" $deployStageActionInputArtifact = New-Object Amazon.CodePipeline.Model.InputArtifact $deployStageActionInputArtifact.Name = "MyApp" $deployStageAction.ActionTypeId = @{"Category" = "Deploy"; "Owner" = "AWS"; "Provider" = "CodeDeploy"; "Version" = 1} $deployStageAction.Configuration.Add("ApplicationName", "CodePipelineDemoApplication") $deployStageAction.Configuration.Add("DeploymentGroupName", "CodePipelineDemoFleet") $deployStageAction.InputArtifacts.Add($deployStageActionInputArtifact) $deployStageAction.Name = "CodePipelineDemoFleet" $sourceStage = New-Object Amazon.CodePipeline.Model.StageDeclaration $deployStage = New-Object Amazon.CodePipeline.Model.StageDeclaration $sourceStage.Name = "Source" $deployStage.Name = "Beta" $sourceStage.Actions.Add($sourceStageAction) $deployStage.Actions.Add($deployStageAction) $pipeline.ArtifactStore = @{"Location" = "amzn-s3-demo-bucket"; "Type" = "S3"} $pipeline.Name = "CodePipelineDemo" $pipeline.RoleArn = "arn:aws:iam::80398EXAMPLE:role/CodePipelineServiceRole" $pipeline.Stages.Add($sourceStage) $pipeline.Stages.Add($deployStage) $pipeline.Version = 1 New-CPPipeline -Pipeline $pipeline

輸出:

ArtifactStore : Amazon.CodePipeline.Model.ArtifactStore Name : CodePipelineDemo RoleArn : arn:aws:iam::80398EXAMPLE:role/CodePipelineServiceRole Stages : {Source, Beta} Version : 1
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 CreatePipeline

下列程式碼範例示範如何使用 Remove-CPCustomActionType

for PowerShell 工具

範例 1:此範例會刪除指定的自訂動作。在繼續之前,命令會提示您進行確認。新增 -Force 參數以刪除自訂動作,而無需提示。

Remove-CPCustomActionType -Category Build -Provider MyBuildProviderName -Version 1

下列程式碼範例示範如何使用 Remove-CPPipeline

for PowerShell 工具

範例 1:此範例會刪除指定的管道。在繼續之前,命令會提示您進行確認。新增 -Force 參數,以在沒有提示的情況下刪除管道。

Remove-CPPipeline -Name CodePipelineDemo
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 DeletePipeline

下列程式碼範例示範如何使用 Start-CPPipelineExecution

for PowerShell 工具

範例 1:此範例會開始執行指定的管道。

Start-CPPipelineExecution -Name CodePipelineDemo

下列程式碼範例示範如何使用 Update-CPPipeline

for PowerShell 工具

範例 1:此範例會使用指定的設定更新指定的現有管道。

$pipeline = New-Object Amazon.CodePipeline.Model.PipelineDeclaration $sourceStageAction = New-Object Amazon.CodePipeline.Model.ActionDeclaration $deployStageAction = New-Object Amazon.CodePipeline.Model.ActionDeclaration $sourceStageActionOutputArtifact = New-Object Amazon.CodePipeline.Model.OutputArtifact $sourceStageActionOutputArtifact.Name = "MyApp" $sourceStageAction.ActionTypeId = @{"Category" = "Source"; "Owner" = "AWS"; "Provider" = "S3"; "Version" = 1} $sourceStageAction.Configuration.Add("S3Bucket", "amzn-s3-demo-bucket") $sourceStageAction.Configuration.Add("S3ObjectKey", "my-object-key-name.zip") $sourceStageAction.OutputArtifacts.Add($sourceStageActionOutputArtifact) $sourceStageAction.Name = "Source" $deployStageActionInputArtifact = New-Object Amazon.CodePipeline.Model.InputArtifact $deployStageActionInputArtifact.Name = "MyApp" $deployStageAction.ActionTypeId = @{"Category" = "Deploy"; "Owner" = "AWS"; "Provider" = "CodeDeploy"; "Version" = 1} $deployStageAction.Configuration.Add("ApplicationName", "CodePipelineDemoApplication") $deployStageAction.Configuration.Add("DeploymentGroupName", "CodePipelineDemoFleet") $deployStageAction.InputArtifacts.Add($deployStageActionInputArtifact) $deployStageAction.Name = "CodePipelineDemoFleet" $sourceStage = New-Object Amazon.CodePipeline.Model.StageDeclaration $deployStage = New-Object Amazon.CodePipeline.Model.StageDeclaration $sourceStage.Name = "MyInputFiles" $deployStage.Name = "MyTestDeployment" $sourceStage.Actions.Add($sourceStageAction) $deployStage.Actions.Add($deployStageAction) $pipeline.ArtifactStore = @{"Location" = "amzn-s3-demo-bucket"; "Type" = "S3"} $pipeline.Name = "CodePipelineDemo" $pipeline.RoleArn = "arn:aws:iam::80398EXAMPLE:role/CodePipelineServiceRole" $pipeline.Stages.Add($sourceStage) $pipeline.Stages.Add($deployStage) $pipeline.Version = 1 Update-CPPipeline -Pipeline $pipeline

輸出:

ArtifactStore : Amazon.CodePipeline.Model.ArtifactStore Name : CodePipelineDemo RoleArn : arn:aws:iam::80398EXAMPLE:role/CodePipelineServiceRole Stages : {InputFiles, TestDeployment} Version : 2
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 UpdatePipeline