Reputation: 755
There are 2 scenarios where a PR marks as "Failed", when ideally it would show as "Pending" or no status.
When a new event is triggered, it terminates the previous build (as expected)
Build was terminated by pipeline policy - new build triggered by pull-request on branch
<my-branch>
This is all great, but the build then shows as "Failed" on GitHub. Theoretically, the new build would undo the "failed" status, but this can take quite some time, and it is difficult to follow what the latest running build is. My terminationPolicy
spec looks like this:
terminationPolicy:
- type: branch
event: onCreate
Termination Policy Docs: https://codefresh.io/docs/docs/integrations/codefresh-api/?#full-pipeline-specification
We want to bypass the build based on labels applied. Ex: "skip-test"
, or be able to run tests without the limitations of the branchRegex
.
steps:
harakiri:
...
commands:
- codefresh terminate ${{CF_BUILD_ID}}
when:
condition:
any:
isWorkInProgress: "match('${{CF_PULL_REQUEST_LABELS}}', 'WIP', false) == true"
Again, works great. But marks the PR as "failed".
If there were a way to inject a command into either of these, I could work with that. But how we have it laid out, it requires entire step to change the status to "Pending". (so I can't simply add an extra "command" to the harakiri
step)
Any thoughts?
Upvotes: 0
Views: 192
Reputation: 1
Scenario 1
I can suggest you use github-status-updater with hooks (instead of default status updates)
So basically it will set pending
status at the build start (and will keep this status if it's terminated by policy).
hooks:
on_success:
title: Set GitHub deployment status to "success"
image: cloudposse/github-status-updater
environment:
- GITHUB_ACTION=update_state
- GITHUB_TOKEN=${{GITHUB_TOKEN}}
- GITHUB_OWNER=${{CF_REPO_OWNER}}
- GITHUB_REPO=${{CF_REPO_NAME}}
- GITHUB_REF=${{CF_REVISION}}
- GITHUB_CONTEXT=Codefresh CI - Build
- GITHUB_STATE=success
- GITHUB_TARGET_URL=${{CF_BUILD_URL}}
on_fail:
title: Set GitHub deployment status to "failure"
image: cloudposse/github-status-updater
environment:
- GITHUB_ACTION=update_state
- GITHUB_TOKEN=${{GITHUB_TOKEN}}
- GITHUB_OWNER=${{CF_REPO_OWNER}}
- GITHUB_REPO=${{CF_REPO_NAME}}
- GITHUB_REF=${{CF_REVISION}}
- GITHUB_CONTEXT=Codefresh CI - Build
- GITHUB_STATE=failure
- GITHUB_TARGET_URL=${{CF_BUILD_URL}}
on_elected:
title: Set GitHub deployment status to "pending"
image: cloudposse/github-status-updater
environment:
- GITHUB_ACTION=update_state
- GITHUB_TOKEN=${{GITHUB_TOKEN}}
- GITHUB_OWNER=${{CF_REPO_OWNER}}
- GITHUB_REPO=${{CF_REPO_NAME}}
- GITHUB_REF=${{CF_REVISION}}
- GITHUB_CONTEXT=Codefresh CI - Build
- GITHUB_STATE=pending
- GITHUB_TARGET_URL=${{CF_BUILD_URL}}
To disable default status updates patch the pipeline spec with CLI
codefresh get pip <name> -o yaml > file.yml
spec:
options:
enableNotifications: false
codefresh replace -f file.yml
Upvotes: 0