Posted on Leave a comment

Manual user approval for pipeline execution

In Azure DevOps pipelines you can use approvals in order to allow or not the deployment based on user input on a pipeline.

Find my article on how to create approvals on build and release pipelines below.

But what happens if you want to run some tasks, get user input and then continue with some other tasks? For this reason you could use the Manual Validation task. As the name indicates, you can validate the user input and perform actions based on this input.

If you approve the execution then the pipeline will continue and if not the pipeline will stop.

You can then use the result of the previous job in order to perform other actions with succeeded() or failed() conditions.

An example of the Validation Task is shown below:

trigger:
- none

pool:
  vmImage: ubuntu-latest

jobs:
- job: job1
  pool: server
  steps:
  - task: ManualValidation@0
    inputs:
      notifyUsers: 'someone@kati.com'
      instructions: 'continue?'

- job: job2
  dependsOn: job1
  steps:
  - script: echo Hello, world!
    displayName: 'Run a one-line script'

The ManualValidation should be used mandatory with pool:server as shown above because it is an agentless job and cannot be run on the standard agent pools.

The job2 as it depends from job1 will run only if the approval is not rejected from the user.

Posted on Leave a comment

Change name for Azure devops pipeline

A common requirement when you work on your pipelines would be to name them according to your needs.

By default Azure devops name your pipeline with the buildID and the commit that initiated the build as shown below.

In order to change the name of the pipeline you can use the name keyword.

name: mypipeline

trigger:
- none

pool:
  vmImage: ubuntu-latest

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

Then you will have your custom name in the run of the pipeline.

Also from September 2022 and later, you can also remove the commit message from the title using appendCommitMessageToRunName

So by also adding this option

name: mypipeline
appendCommitMessageToRunName: false

trigger:
- none

pool:
  vmImage: ubuntu-latest

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

I will get only my preferred name on the pipeline run.

YouTube tutorial:

Posted on Leave a comment

Your branch is behind origin/main by 1 commit and can be fast-forwarded

Sometimes when you work on a repository you may have commited a change locally that is not pushed to the remote branch. As git is a collaborative platform other people may have commited in your branch and you may need to perform a git pull in order to get the latest changes.

Lets examine a common scenario on which you left behind your local branch. By executing git status we see that one commit that is performed on the local copy is not pushed.

The latest commit in the remote is the one with hash d82186bf6fbfdc8bb38ab5bd12b4bc170b550b7c

However the latest commit in the local repository (not in the same version as the remote) is the one shown below with the hash cd4a8c6f336fa5f7afad7d7d53d2555b7c87aabe and cannot be pulled because there are conflicts with my local commits.

When you have such conflicts you should define what you need to do. In my case I wanted to abort my local commit and get the latest version of the repository.

In order to do so

git reset --hard origin/main

Then by getting the status and pulling you will verify that the latest commit is the one that is the most recent on the repository and your local changes have been discarded.

Posted on Leave a comment

JMeter Introduction – Load test your website

The Apache JMeter™ application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance.

You can download from the official webpage and install it for your system given than you already have Java installed.

For windows installations the only thing that you need to do, will be to run as Administrator the jmeter.bat file.

Then you can access the GUI and perform actions with clicks. In this guide I will demonstrate how you can create an http call on your website and perform a load test on it.

In order to start you will need to add a thread group. Right click on test plan and then click threads and select thread group.

Inside the thread group you can create a HTTP Request action. In order to do that you will select add Sampler and then from the available Samplers you will select the HTTP Request.

ON the HTTP Request you will need to configure the host and also the protocol. As my site is working on https I will use this one along with the port 443.

Additionally you can add a listener on your HTTP Request in order to get the results either with a Graph or with a table. To add the result output you will have to press Listener and then select the one that you want.

The below result will be the aggregate report which will show statistics for the requests.

We can also visualize the results using a Graph result

The most important part of the configuration will be the Thread group options which can be found under Thread Group.

There you can configure the below three important things:

Number of threads: Each thread will execute the test plan in its entirety and completely independently of other test threads. Multiple threads are used to simulate concurrent connections to your server application.

The ramp-up period is the time JMeter should take to start the total number of threads, the time frame (in seconds) for all requests to start. All the threads specified in the Number of Threads input will start within Ramp-up period. For example 100 threads and 100 seconds ramp-up: each second JMeter will start 1 Thread until all threads are started by the time the 100 seconds are up.

The loop count tells JMeter how many times to repeat your test. If you enter a loop count value of 1, then JMeter will run your test only once. To have JMeter repeatedly run your Test Plan, select the Forever checkbox.