Azure DevOps : Pipeline and parameters

Thought to document how I configure Azure devops to run the test suite Im working on as it was experimental. I do not have Azure Devops experience so this is me trying out different options to make it work to my liking.

Thought documenting it all in one place is a good idea.

Tech stack

Java version 20, Cucumber, Maven, Selenium, Azure Devops Dev19

Requirement

Ability to run the test suite with parameters and generate test artefacts.

Experiment with parameters

Hard coded parameters

The environment is taken as a parameter and it is defined under variables. The value is referred later in the steps – see highlighted above.

User Azure Devops inbuilt Variables option

Azure DevOps provides it own variables. These can be used at the time of Pipeline run.

Navigate to the yaml file and Click on variables

And add the variable you require. Here I go with environment. I am going to select “Let users override this value when running this pipeline” option as well. You can have the Value blank or set a default value. If you want this value to be changed at run time, you need to select “Let users override this value when running this pipeline” option.

So we can remove the variables section from the yaml file. I have commented that section to show where it was before. The way of using the variable had not changed.

So when I run the test, I can navigate to Variables and change the environment to what you require. You will see the newly defined variables under Advanced options when you click Run Pipeline.

If you want to change the default value, you can click on the variable that need changed.

You can see that I have changed the default value of GB to US.

Let users select the values as parameters

The disadvantage of using Variables is that user have to enter the values manually if the value need changing from default. There is a possibility of misspelled words, entering options that the code is not ready to handle etc.

I prefer providing pre-define list of parameters to the users to choose from. That you can do via Parameters in yaml file.

In following screen you can see that I have few pre-defined parameters. I have a parameter called Environment and it shows all the different environments that is handled. The way of using the parameter later in the file has changed too.

When you click on Run Pipeline, then you can select the pre-defined values.

Configure the pipeline run to be more user friendly

Great! All setup with parameters and now you start running different combinations of tests and they all look like below.

There is no way I can clearly understand what build run for what parameter configuration. To improve this. we can add a name in the yaml file.

Please note that no special characters can be used on the name – learnt it on the hard way.

So the build will look as below. Instead of a build no, I can see the the parameter combination.

However, you still see the build commit message. We can remove the build commit message from the pipeline by setting the following option to false.

Then when you run the build, you get a much cleaner title. Ta da!!

Are there more cooler things I can do? Let me know…

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

close-alt close collapse comment ellipsis expand gallery heart lock menu next pinned previous reply search share star