Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test Azure Pipelines

Is any possibility to test created Azure Pipelines? From UI or your yaml definition of pipelines?

Mean that I have some yamls pipelines or pipelines defined from UI and I want to ensure by some tests(Unit Tests e.x.) that all have defined variables, build, test, and package parts or something else in each pipeline.

And verify pipelines configurations after some changes of them or after adding some new repos/branches if it's required.

Thanks...

like image 995
subKiller Avatar asked Nov 15 '25 20:11

subKiller


1 Answers

Is any possibility to test created Azure Pipelines? From UI or your yaml definition of pipelines?

If you want a out of box feature to achieve this, sorry to say, No, there hasn't.

BUT, the work around is using API to check them.

  • Client API.

You could write a simple script to get Builds definition with Client API.

In this simple script, you first get the whole definition:

List<BuildDefinitionReference> buildDefinitions = new List<BuildDefinitionReference>();

Then you could apply your customized check/test into this definition with scripts. In one word, write some test classes/methods. After the script complete, you can import it into VSTS, and then use task to run those tests part. Only this test succeed, then your builds could be executed.

So, at this time, it need you add 2 agent jobs into your pipeline, the first one is used to run your script test(names test agent job). And the second agent job is the one you want to check. In the second agent job, set its condition as:

enter image description here

At this time, only the test succeed, this current job can be ran.

Or, if you don't want the builds you want to check would be broken because of the test, please consider about using Build completion trigger. Set a separate pipeline to run the test. In the pipeline you want to check, set it can be run only when the test pipeline finished.

enter image description here


  • Rest API

You could use rest api with powershell which very similar with the above description. Use api to get builds definition, and then write some check powershell script.


I more recommend you to put the test at a separate pipeline. Then the API could only get the part you want check, not including the test part.

like image 198
Mengdi Liang Avatar answered Nov 17 '25 15:11

Mengdi Liang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!