CodePipeline contoh menggunakan Alat untuk PowerShell - AWS SDKContoh Kode

Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen.

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

CodePipeline contoh menggunakan Alat untuk PowerShell

Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan AWS Tools for PowerShell with CodePipeline.

Tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

Tindakan

Contoh kode berikut menunjukkan cara menggunakanConfirm-CPJob.

Alat untuk PowerShell

Contoh 1: Contoh ini mendapatkan status pekerjaan yang ditentukan.

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

Output:

Value ----- InProgress
  • Untuk API detailnya, lihat AcknowledgeJobdi AWS Tools for PowerShell Referensi Cmdlet.

Contoh kode berikut menunjukkan cara menggunakanDisable-CPStageTransition.

Alat untuk PowerShell

Contoh 1: Contoh ini menonaktifkan transisi masuk untuk tahap tertentu dalam pipeline yang ditentukan.

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

Contoh kode berikut menunjukkan cara menggunakanEnable-CPStageTransition.

Alat untuk PowerShell

Contoh 1: Contoh ini memungkinkan transisi inbound untuk tahap tertentu dalam pipeline yang ditentukan.

Enable-CPStageTransition -PipelineName CodePipelineDemo -StageName Beta -TransitionType Inbound

Contoh kode berikut menunjukkan cara menggunakanGet-CPActionType.

Alat untuk PowerShell

Contoh 1: Contoh ini mendapatkan informasi tentang semua tindakan yang tersedia untuk pemilik yang ditentukan.

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) }

Output:

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}
  • Untuk API detailnya, lihat ListActionTypesdi AWS Tools for PowerShell Referensi Cmdlet.

Contoh kode berikut menunjukkan cara menggunakanGet-CPActionableJobList.

Alat untuk PowerShell

Contoh 1: Contoh ini mendapatkan informasi tentang semua pekerjaan yang dapat ditindaklanjuti untuk kategori tindakan tertentu, pemilik, penyedia, versi, dan parameter kueri.

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

Output:

AccountId Data Id Nonce --------- ---- -- ----- 80398EXAMPLE Amazon.CodePipeline.Model.JobData 0de392f5-712d-4f41-ace3-f57a0EXAMPLE 3
  • Untuk API detailnya, lihat PollForJobsdi AWS Tools for PowerShell Referensi Cmdlet.

Contoh kode berikut menunjukkan cara menggunakanGet-CPJobDetail.

Alat untuk PowerShell

Contoh 1: Contoh ini mendapatkan informasi umum tentang pekerjaan yang ditentukan.

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

Output:

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

Contoh 2: Contoh ini mendapatkan informasi rinci tentang pekerjaan yang ditentukan.

$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)

Output:

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
  • Untuk API detailnya, lihat GetJobDetailsdi AWS Tools for PowerShell Referensi Cmdlet.

Contoh kode berikut menunjukkan cara menggunakanGet-CPPipeline.

Alat untuk PowerShell

Contoh 1: Contoh ini mendapatkan informasi umum tentang pipeline yang ditentukan.

Get-CPPipeline -Name CodePipelineDemo -Version 1

Output:

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

Contoh 2: Contoh ini mendapatkan informasi rinci tentang pipeline yang ditentukan.

$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) } }

Output:

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
  • Untuk API detailnya, lihat GetPipelinedi AWS Tools for PowerShell Referensi Cmdlet.

Contoh kode berikut menunjukkan cara menggunakanGet-CPPipelineList.

Alat untuk PowerShell

Contoh 1: Contoh ini mendapatkan daftar pipeline yang tersedia.

Get-CPPipelineList

Output:

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
  • Untuk API detailnya, lihat ListPipelinesdi AWS Tools for PowerShell Referensi Cmdlet.

Contoh kode berikut menunjukkan cara menggunakanGet-CPPipelineState.

Alat untuk PowerShell

Contoh 1: Contoh ini mendapatkan informasi umum tentang tahapan untuk pipeline yang ditentukan.

Get-CPPipelineState -Name CodePipelineDemo

Output:

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

Contoh 2: Contoh ini mendapatkan informasi rinci tentang keadaan pipa yang ditentukan.

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) } }

Output:

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 =
  • Untuk API detailnya, lihat GetPipelineStatedi AWS Tools for PowerShell Referensi Cmdlet.

Contoh kode berikut menunjukkan cara menggunakanNew-CPCustomActionType.

Alat untuk PowerShell

Contoh 1: Contoh ini membuat tindakan kustom baru dengan properti yang ditentukan.

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

Output:

ActionConfigurationProperties : {ProjectName} Id : Amazon.CodePipeline.Model.ActionTypeId InputArtifactDetails : Amazon.CodePipeline.Model.ArtifactDetails OutputArtifactDetails : Amazon.CodePipeline.Model.ArtifactDetails Settings : Amazon.CodePipeline.Model.ActionTypeSettings

Contoh kode berikut menunjukkan cara menggunakanNew-CPPipeline.

Alat untuk PowerShell

Contoh 1: Contoh ini membuat pipeline baru dengan pengaturan yang ditentukan.

$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

Output:

ArtifactStore : Amazon.CodePipeline.Model.ArtifactStore Name : CodePipelineDemo RoleArn : arn:aws:iam::80398EXAMPLE:role/CodePipelineServiceRole Stages : {Source, Beta} Version : 1
  • Untuk API detailnya, lihat CreatePipelinedi AWS Tools for PowerShell Referensi Cmdlet.

Contoh kode berikut menunjukkan cara menggunakanRemove-CPCustomActionType.

Alat untuk PowerShell

Contoh 1: Contoh ini menghapus tindakan kustom yang ditentukan. Perintah akan meminta konfirmasi sebelum melanjutkan. Tambahkan parameter -Force untuk menghapus tindakan kustom tanpa prompt.

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

Contoh kode berikut menunjukkan cara menggunakanRemove-CPPipeline.

Alat untuk PowerShell

Contoh 1: Contoh ini menghapus pipeline yang ditentukan. Perintah akan meminta konfirmasi sebelum melanjutkan. Tambahkan parameter -Force untuk menghapus pipeline tanpa prompt.

Remove-CPPipeline -Name CodePipelineDemo
  • Untuk API detailnya, lihat DeletePipelinedi AWS Tools for PowerShell Referensi Cmdlet.

Contoh kode berikut menunjukkan cara menggunakanStart-CPPipelineExecution.

Alat untuk PowerShell

Contoh 1: Contoh ini mulai menjalankan pipeline yang ditentukan.

Start-CPPipelineExecution -Name CodePipelineDemo

Contoh kode berikut menunjukkan cara menggunakanUpdate-CPPipeline.

Alat untuk PowerShell

Contoh 1: Contoh ini memperbarui pipeline yang ada yang ditentukan dengan pengaturan yang ditentukan.

$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

Output:

ArtifactStore : Amazon.CodePipeline.Model.ArtifactStore Name : CodePipelineDemo RoleArn : arn:aws:iam::80398EXAMPLE:role/CodePipelineServiceRole Stages : {InputFiles, TestDeployment} Version : 2
  • Untuk API detailnya, lihat UpdatePipelinedi AWS Tools for PowerShell Referensi Cmdlet.