Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check if Job succeeded or failed? #4939

Open
PedroAlvarado opened this issue May 29, 2023 · 2 comments
Open

How to check if Job succeeded or failed? #4939

PedroAlvarado opened this issue May 29, 2023 · 2 comments
Labels
area/job Issues about jobs. type/feature Issues that are new feature requests. type/request Issues that are created by customers.

Comments

@PedroAlvarado
Copy link

PedroAlvarado commented May 29, 2023

We have a multi-step GitHub action. One of the steps is running a job (“job run”). We’d like to continue to the next GitHub action step only after the job completed successfully.

Is there a recommended(copilot idiomatic) approach to being able to implement such functionality?

Please note that we are using “on.schedule: “none””.

@bvtujo bvtujo added type/feature Issues that are new feature requests. type/request Issues that are created by customers. area/job Issues about jobs. labels Jun 5, 2023
@bvtujo
Copy link
Contributor

bvtujo commented Jun 5, 2023

Hey, this is a great feature request for us. It seems like a natural use case for a job status command. Thanks for surfacing this need so we can prioritize it.

In the meantime, can you work around your problem with these AWS CLI commands?

# Grab the ARN of the state machine some way (you can replace this with a variable, like so:
# STATE_MACHINE_ARN=arn:aws:states:$REGION:$ACCOUNT_ID:stateMachine:$COPILOT_APP-$COPILOT_ENV-$COPILOT_JOB
STATE_MACHINE_ARN=$(aws stepfunctions list-state-machines | jq -r '.stateMachines[].stateMachineArn')

# List the last execution of the state machine and parse its status
STATE_MACHINE_EXIT_CODE=$(aws stepfunctions list-executions --state-machine-arn $ARN --max-results 1 | jq -r '.executions[].status')

You can then do something with the STATE_MACHINE_EXIT_CODE variable.

If you have access to the state machine execution ARN, you can use aws stepfunctions describe-execution instead for similar results.

@vshah11
Copy link

vshah11 commented Feb 12, 2024

@PedroAlvarado I came across a similar issue for one of my projects and wanted to know if you found any solution to your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/job Issues about jobs. type/feature Issues that are new feature requests. type/request Issues that are created by customers.
Projects
None yet
Development

No branches or pull requests

3 participants