Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

How can I fail the Azure Pipeline when thresholds are exceeded? #8

Open
cvdabbeele opened this issue Aug 12, 2020 · 3 comments
Open

Comments

@cvdabbeele
Copy link

Hi,
Unlike on AWS CodePipeline, the ("my") Azure Pipeline does not fail if the findings of smartcheck-scan-action exceed the thresholds. Is there any way I can make the Azure Pipeline not go to the next job if the findings are higher than the thresholds?
thanks,
chris

@OzNetNerd
Copy link

OzNetNerd commented Aug 12, 2020

I ran into a similar with AWS' CodePipeline & CodeBuild. The pipeline continues for debugging purposes.

I got the desired outcome by looking at the CODEBUILD_BUILD_SUCCEEDING environment variable.

Here's a snippet from the pipeline:

            post_build:
              commands:
                - bash -c "if [ /"$CODEBUILD_BUILD_SUCCEEDING/" == /"0/" ]; then exit 1; fi"
                - echo Build completed on `date`
                - echo Pushing the Docker image...
                - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG

Hopefully this helps with an Azure solution.

@cvdabbeele
Copy link
Author

thank you @OzNetNerd,
I tried it in Azure Pipelines, but is seems that that variable has no content, regardless of the scanresults
chris

@OzNetNerd
Copy link

OzNetNerd commented Aug 13, 2020

No worries @cvdabbeele.

CODEBUILD_BUILD_SUCCEEDING is an AWS environment variable. Perhaps the Azure equivalent is Agent.JobStatus (reference).

You can use agent variables as environment variables in your scripts and as parameters in your build tasks.

Agent.JobStatus: The status of the build.

* Canceled
* Failed
* Succeeded
* SucceededWithIssues (partially successful)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants