Windows: Set Environment Variable – CMD & PowerShell

What is an environment variable in Windows? An environment variable is a dynamic “object” containing an editable value which may be used by one or more software programs in Windows.

In this note i am showing how to set an environment variable in Windows from the command-line prompt (CMD) and from the Windows PowerShell.

In the examples below i will set an environment variable temporary (for the current terminal session only), permanently for the current user and globally for the whole system. (more…)

Windows: `Grep` Equivalent – CMD & PowerShell

The grep command in Linux is widely used for parsing files and searching for useful data in the outputs of different commands.

The findstr command is a Windows grep equivalent in a Windows command-line prompt (CMD).

In a Windows PowerShell the alternative for grep is the Select-String command.

Below you will find some examples of how to “grep” in Windows using these alternatives. (more…)

Jenkins Pipeline: Conditionally Define Variables – Groovy Script

The Groovy scripting language supports conditional structures, that can be used in Jenkins pipelines.

Assume that you have a parametrized Jenkins job and in a Jenkinsfile you have a variable that should be defined depending on provided parameters.

Here is an example of how to conditionally define variables in a Jenkins pipeline using the Groovy scripting language syntax. (more…)

SSH: Create Public Key from Private

Usually a public SSH key is generated at the same time as a private key.

Unlike a private SSH key, it is acceptable to lose a public key as it can be generated again from a private key at any time.

In this small note i am showing how to create a public SSH key from a private one using ssh-keygen command-line tool. (more…)

Git – Squash Commits: Merge All Commits in Branch Into One

Each time you are working on a bug or a feature, you create a branch for it.

Usually, while working in such temporary branches, you make multiply commits without bothering a lot about commit messages and simply comment the changes with something like “work in progress” or just “WIP”.

Before merging such branch into master it is a good practice to squash all commits in one with a single commit message that describes the summary of the changes.

Below i will show you how to squash commits in Git before merging a branch into master. (more…)