SREENIVASA REDDY
SREENIVASA REDDY

Reputation: 1

Mark jenkins job as success/Failed based on the status of aws codepipline execution

I have a jenkins job which uses execute shell as a build phase. I'm calling 3 AWS Codepipeline executions using aws cli command from this shell. My codepipeline execution takes 4-5 mins to complete the execution but jenkins job is marked as success before the completion of pipeline and even if the pipeline has failed in at any stage.

Is there a way to make jenkins job to complete only after execution of codepipeline is completed amd mark the Jenkins job success/failed based on the status of my aws code-pipeline.

OR

How can i mark the jenkins job as Success/Failed based on the status of my aws code-pipeline.

Upvotes: 0

Views: 377

Answers (1)

shariqmaws
shariqmaws

Reputation: 8890

'start-pipeline-execution' is an asynchronous operation. You need to keep polling the status of the execution to know the result.

In your Jenkins job, when you have started the pipeline using start-pipeline-execution, then you will need to keep querying the pipeline execution id using get-pipeline-execution CLI call [1] and keep checking the status for a sane amount of time (say 1 hour) in a loop. When get-pipeline-execution return status='Succeeded', exit with a 0 from Jenkins, if it is 'Failed', exit with -1 in the shell step to fail the Jenkins job.

exit -1

Upvotes: 1

Related Questions