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

Publishing artifacts from a failed step #608

Open
frerikandriessen opened this issue Apr 3, 2024 · 1 comment
Open

Publishing artifacts from a failed step #608

frerikandriessen opened this issue Apr 3, 2024 · 1 comment

Comments

@frerikandriessen
Copy link

I have the following usecase:

I have a job that runs tests (could be unit-tests, or a vulnerability scanner, you name it) of which I want to publish the resulting report.
When this job runs, and we get to the publish step, there are 3 possible options:

  1. The tests have run successfully. The report should be published
  2. The tests have run but failed. The report should be published
  3. A step somewhere before the test-running step has failed. Thus the tests have not run. There is no report to publish and thus this publish step should not run.

What is your advice/pattern in this (imo) pretty normal usecase? Or am I mistaken and is this not a normal usecase / am I using the tool wrong?

I would have expected to be able to use a condition to refer to the specific test-step, and to only run the publish-step when this test-step has been run.
Or even better, to be able to check in the condition if the report exists.
As far as I understand it, both of these options are not possible.

I'd be happy to hear what your suggested approach is here.

@aleksandrlevochkin
Copy link

Hi @frerikandriessen, thank you for your question.

I would have expected to be able to use a condition to refer to the specific test-step, and to only run the publish-step when this test-step has been run.

You can specify a condition for a step based on the variable created from another step: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml%2Cstages#use-the-pipeline-variable-created-from-a-step-in-a-condition-in-a-subsequent-step

Or even better, to be able to check in the condition if the report exists.

I am not sure if it's helpful in your particular case, but you may check out conditional expressions: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#conditional-insertion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants