Posted on Leave a comment

Download repos with ssh keys on Gitlab with MFA enabled

When you enable MFA in Gitlab you may face issues when interacting with git repositories. Some of your commands like git pull, push etc could fail and this is done because of the MFA.

There is a way to resolve those issues by communicating with ssh keys. The procedure to create and upload your keys are described in the below article.

However sometimes this may not work as in my case. The issue was that the ssh key for some reason could not be found correctly from the computer.

In order to bypass I used the ssh-add command and then pointed the directory of the key.

ssh-add ~/.ssh/gitlab_id_rsa

After this action your gitlab interaction will start working.

Posted on Leave a comment

Azure DevOps inventory – export data for devops organization

Inventory is necessary for many organizations when it comes to technology tools and services. As Azure devops is a complex tool which includes many services such as Repositories, Pipelines, Test Runs and more, you may want some times to export a dump of the created assets inside your DevOps account.

Using the below powershell script, you can export

  • Agent pools
  • Agents
  • Repositories
  • Projects
  • Pipelines

The first version of the tool will display all the information gathered through Azure DevOps REST API on the output console. On future versions I will improve the output and also the gathered information.

You can execute the inventory script by following the instructions on Github. The only thing that you will need to provide is a PAT token inside the $organizations hashtable.

$organizations= @(

After the execution you will get the information in the console output.

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 1 Comment

Parameters and variables – GitHub workflows

Variables and parameters can be used on GitHub workflows in order to provide input and store temporary values that should be passed on tasks. When you need to ask for user input one should use the parameters and when that is not necessary variables is the preferred way to go.

We will now examine how we can use both in a github workflow.

You can define an input parameter using the inputs keyword. Using the code below you can run a workflow manually. The input that is requested is a string and the description is the message that will be shown to the user.

  # Allows you to run this workflow manually from the Actions tab
        description: "give me your username"
        default: "geralexgr"
        type: "string"

Then later in the workflow you can use the value of the input using inputs.username

The below job will show the input of the user:

    runs-on: ubuntu-latest
      - name: task inside job1
        run: |
          echo The username is ${{ inputs.username }}

Variables on the other hand can be used during runtime. Similar to using default environment variables, you can use custom environment variables in your workflow actions. To create a custom variable, you need to define it in your workflow file using the env context.

      - name: print variable
          NAME: "Gerasimos"
        run: |
          echo Variable name is: $NAME

During workflow run the variable will be printed on the output.

Youtube tutorial: