Use GetJobDetails with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use GetJobDetails with an AWS SDK or CLI

The following code examples show how to use GetJobDetails.

CLI
AWS CLI

To get details of a job

This example returns details about a job whose ID is represented by f4f4ff82-2d11-EXAMPLE. This command is only used for custom actions. When this command is called, AWS CodePipeline returns temporary credentials for the Amazon S3 bucket used to store artifacts for the pipeline, if required for the custom action. This command will also return any secret values defined for the action, if any are defined.

Command:

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" } }
  • For API details, see GetJobDetails in AWS CLI Command Reference.

PowerShell
Tools for PowerShell

Example 1: This example gets general information about the specified job.

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

Output:

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

Example 2: This example gets detailed information about the specified job.

$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
  • For API details, see GetJobDetails in AWS Tools for PowerShell Cmdlet Reference.