Bartosz Bierkowski - Low dose cloud

OpenShift CLI morsels: Building application from private git repository

Having a public repository is a great thing, but not always possible or useful. OpenShift supports git access using ssh private keys and password. Below you can find the few steps on how you can use basic authentication

The ssh private key and passwords are obviously secrets and this is a mechanism that should be used to pass these credentials to git inside the build container.

Creating secret with basicauth

I prefer using the --prompt  flag to interactively enter the password and then the credentials are not stored in bash history. You can also use --password=abc123  parameter to provide it the password. The username parameter is optional.

You can see the created secret below. The password and username are base64 encoded.

Configuring the build config

The secret has to be added to build config that should use it.

Last two lines above configure the secret in the build.

Starting new build

If the config trigger is not configured on the build, it can be started directly

Bitbucket application passwords

If you are using a private repositories in bitbucket, you can use app passwords feature to access your repositories from local OpenShift instance.

Application passwords allow you to create passwords for your user with which you can access bitbucket with lower privileges. For example you will be able to only read repositories.

Check out the announcement with couple screenshots: Bitbucket blog: App passwords


The basic authentication in builds is described at OpenShift: Source secrets basic authentication. The page contains also a lot of useful information about secrets in general.


The commands were executed using minishift and the following client/server versions of OpenShift.

oc v1.4.1+3f9807a
client kubernetes v1.4.0+776c994
openshift v1.5.0+031cbe4
server kubernetes v1.5.2+43a9be4


Thanks for reading the OpenShift morsels. To get updates about new articles, you can sign up to the newsletter below.

As a thank you message, you will also get access to OpenShift CLI CheatSheet listing most commonly used commands together with a short explanation.

Did you like the article?
Join the newsletter to receive notifications about new articles.
I respect your privacy.