Azure Devops API Release test results - azure

I've got a couple of questions.
I'm trying to use the Azure DevOps API to get the test results from a release, the release has multiple tests that are listed separately in the test runs i.e they have different RunID numbers. What URI do I use to get the actual test results the way it's displayed if you click on the test results from within the release pipeline. If this cannot be done, how do I get all of the test results relating to one release and output the fail and success total of them added together.
The other way I've looked at this is to get all of the RunID's from the tests and filter through them matching the release name in the Run to the release name in the release pipeline, but seeing as there are over 1248 runs I don't want to do that.
I'm having trouble getting the run query working I don't know how to set the minLastUpdatedDate={minLastUpdatedDate} or the
maxLastUpdatedDate={maxLastUpdatedDate} are set.
https://learn.microsoft.com/en-us/rest/api/azure/devops/test/runs/query?view=azure-devops-rest-5.0
The documentation doesn't specify the format apart from date-time!
Some examples would be great.

Is DateTime format the main problem here?
"yyyy-MM-dd" and
"MM/dd/yyyy HH:mm:ss"
both worked for me, I guess more would too.
Example:
https://[...]/_apis/test/runs?minLastUpdatedDate=2019-07-02&maxLastUpdatedDate=07/05/2019 16:16:11&releaseIds=243&releaseEnvIds=2899&api-version=5.0

Related

How to exclude gitlab CI job from pipeline based on a value in a project file?

I need to exclude a job from pipeline in case my project version is pre-release.
How I know it's a pre-release?
I set the following in the version info file, that all project files and tools use:
version = "1.2.3-pre"
From CI script, I parse the file, extract the version value, and know whether it's a pre-release or not, and can set the result in an environment variable.
The only way I know to exclude a job from pipeline is to use rules, while, I know also from gitlab docs that:
rules are evaluated before any jobs run
before_script also is claimed to be called with the script, i.e. after applying the rules.
I can stop the job, only after it starts from the script itself, based on the version value, but what I need is to extract the job from the pipeline in the first place, so it's not displayed in the pipeline history. Any idea?
Thanks
How do you run (start) your pipeline, and is the information whether "it's a pre-release" already known at this point?
If yes, then you could add a flag like IS_PRERELEASE as a variable to the pipeline, and use that in the rules: section of your job. The drawback is that this will not work with automatic pipelines (triggered by a commit or MR); but you can use this approach with manually triggered pipelines (https://docs.gitlab.com/ee/ci/variables/#override-a-variable-when-running-a-pipeline-manually) or via the API (https://docs.gitlab.com/ee/ci/triggers/#pass-cicd-variables-in-the-api-call).

Override a defined CI/CD variable in a gitlab job

i am currently facing an issue using Gitlab-ci. i am using gitlab 13.12 community edition.
I want to be able to override the value of a CICD variable from within a gitlab-ci.yml job.
you might say that i could just pass out the value from one job to another but the goal is to change that value so that , on the next pipeline , all my jobs will use the updated one.
To be precise , i want to be able to change MY_CICD_VARIABLE_TO_CHANGE that i've defined in project > cicd > variables. and update this value from a gitlab-ci job
something like this but not only change it for the current pipeline but update it :
change_variable_value:
stage: "change_variable"
image: myimage
script:
- $MY_CICD_VARIABLE_TO_CHANGE="value_changed"
, i tried to do every single solutions specify here :
https://docs.gitlab.com/13.12/ee/ci/variables/index.html#override-a-defined-cicd-variable
nothing seems to work.
I also tried to use artefact but it seems that i am not able to pass artefact between 2 distinct pipelines, they have to be part of the same pipeline , even by curling the api (at least in the community edition)
Any idea is more than welcome :)

How to find child pipeline run id of execute pipeline

I want to find the expression to find the run id of child pipeline of Execute pipeline, currently I am using:
#activity('Execute Pipeline1').Output.pipeline.RunId
which is giving error. How can I access it?
I figured out that the expression "#activity('Execute Pipeline1').output" gives a JSON which is converted to a String and
hence anything beyond the output value is not being parsed as a JSON.
One way to get past this is by using a custom activity chained to the execute pipeline activity and parse it using .NET code.
Hope this helps.

Puppet Development Kit test unit with multiple output targets

We have introduced the PDK lately into our developments chain and are now trying to make everybody happy with the test outputs it generates.
We need an output as JUnit test report for our jenkins jobs. That we have solved.
And we need the output still on the console because some of the developers find it very annoying having to open the JUnit report file before they can see failed tests.
pdk test unit --format=junit:report.xml
Is how we configured the output for JUnit.
Unfortunately as soon as you configure the JUnit report no output gets printed on the console/stdout anymore. Even if you add another format like --format=text without target file.
Is there a way to achieve both without running the PDK twice?
It doesn't appear to be in the docs, but this should work.
pdk test unit --format=junit:report.xml --format=text:stdout
See https://github.com/puppetlabs/pdk/blob/7b2950bc5fb2e88ead7321c82414459540949eb1/lib/pdk/cli/util/option_normalizer.rb#L10-L24
I've filed a ticket to ensure that gets promoted to the docs at https://puppet.com/docs/pdk/1.x/pdk_reference.html#pdk-test-unit-command
From PDK documentation
--format=[:]
Specifies the format of the output. Optionally, you can specify a target file
for the given output format,
such as --format=junit:report.xml . Multiple --format options can be
specified as long as they all have distinct output targets
So I believe ,you can try as below
pdk test unit --tests=testcase_name --format=junit:report.xml --format=text:log.txt
Hope it helps.

How to create a TFS report in Excel showing tests passed and failed per build from tests results published via mstest.exe

Here's what we'd like to do:
A build completes successfully in TFS 2012
Once complete a separate command line process runs tests via vstest.console.exe generating TRX files.
Once all tests have completed those tests/TRXs are published against the target build that just completed using mstest.exe
Once complete we are able to see those published results in Team Explorer - Builds - View Builds for the target build. Under Summary you can see 100 test runs completed for all 100 tests published against it.
At this point we want to open Excel, connect to the TFS Cube and create an Excel report showing a pass/fail pie chart for the target build.
Can someone advise what Cube data to use. We've already tried a few things without success.
Thank you.
We were able to find the target Cube data. Thank you.
Filters - ''
Columns - Outcome, Test Result Executed By
Rows - Build, Test Run ID, Test Run Title, Test Run State
Values - Result Count

Resources