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.
Gunakan GetJobDetails
dengan a CLI
Contoh kode berikut menunjukkan cara menggunakanGetJobDetails
.
- CLI
-
- AWS CLI
-
Untuk mendapatkan detail pekerjaan
Contoh ini mengembalikan rincian tentang pekerjaan yang ID diwakili oleh f4f4ff82-2d11-. EXAMPLE Perintah ini hanya digunakan untuk tindakan kustom. Saat perintah ini dipanggil, AWS CodePipeline mengembalikan kredensi sementara untuk bucket Amazon S3 yang digunakan untuk menyimpan artefak untuk pipeline, jika diperlukan untuk tindakan kustom. Perintah ini juga akan mengembalikan nilai rahasia yang ditentukan untuk tindakan, jika ada yang ditentukan.
Perintah:
aws codepipeline get-job-details --job-id
f4f4ff82-2d11-EXAMPLE
Output:
{ "jobDetails": { "accountId": "111111111111", "data": { "actionConfiguration": { "__type": "ActionConfiguration", "configuration": { "ProjectName": "MyJenkinsExampleTestProject" } }, "actionTypeId": { "__type": "ActionTypeId", "category": "Test", "owner": "Custom", "provider": "MyJenkinsProviderName", "version": "1" }, "artifactCredentials": { "__type": "AWSSessionCredentials", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", "sessionToken": "fICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhcNMTEwNDI1MjA0NTIxWhcNMTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMaK0dn+a4GmWIWJ21uUSfwfEvySWtC2XADZ4nB+BLYgVIk60CpiwsZ3G93vUEIO3IyNoH/f0wYK8m9TrDHudUZg3qX4waLG5M43q7Wgc/MbQITxOUSQv7c7ugFFDzQGBzZswY6786m86gpEIbb3OhjZnzcvQAaRHhdlQWIMm2nrAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAtCu4nUhVVxYUntneD9+h8Mg9q6q+auNKyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0FkbFFBjvSfpJIlJ00zbhNYS5f6GuoEDmFJl0ZxBHjJnyp378OD8uTs7fLvjx79LjSTbNYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE=" }, "inputArtifacts": [ { "__type": "Artifact", "location": { "s3Location": { "bucketName": "codepipeline-us-east-1-11EXAMPLE11", "objectKey": "MySecondPipeline/MyAppBuild/EXAMPLE" }, "type": "S3" }, "name": "MyAppBuild" } ], "outputArtifacts": [], "pipelineContext": { "__type": "PipelineContext", "action": { "name": "MyJenkinsTest-Action" }, "pipelineName": "MySecondPipeline", "stage": { "name": "Testing" } } }, "id": "f4f4ff82-2d11-EXAMPLE" } }
-
Untuk API detailnya, lihat GetJobDetails
di Referensi AWS CLI Perintah.
-
- PowerShell
-
- 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.
-