Skip to main content

Setting your Git credentials on build machines

Abstract

If you want to push back any commits to your own Git repo from Bitrise while running your build, you can set up your Git credentials on build machines.

The default Git username and user email address on our stacks are the following:

git config --global user.email "[email protected]"
git config --global user.name "J. Doe (https://devcenter.bitrise.io/builds/setting-your-git-credentials-on-build-machines/)"

If you want to push back (git push) any commits to your own repo from Bitrise while running your build, you have to set your own username and the email address. There are three ways to achieve this:

  • You can use a custom Script Step to set your credentials with the git config command.

  • You can set your Git credentials as Env Vars.

  • You can use the Set Git Credentials Step.

Setting your Git credentials using Env Vars

Git has various basic Environmental Variables similar to Bitrise Env Vars. If you would like to reduce the amount of Steps in your Workflow, you can set up Env Vars in Bitrise utilizing specific Git Environmental Variables:

  1. Open the Workflow Editor.

  2. Go to the Env Vars tab.

  3. Create the following Env Vars:

    • GIT_AUTHOR_NAME: This is the human-readable name of the “author”.

    • GIT_AUTHOR_EMAIL: This is the email address of the "author".

    • GIT_COMMITTER_NAME: This is the human-readable name of the “committer”.

    • GIT_COMMITTER_EMAIL: This is the email address of the "committer".

    git_credentials.png

Setting your Git credentials using the Set Git Credentials Step

  1. Add a Set Git Credentials Step as the very first step in your workflow. The Step has to come first before you’d git commit. This way you can make sure any changes you make to the current build will be attached to a commit associated with your username and email address.

  2. In the Git Username field, set the value to your own user name.

  3. In the Git Email Address field, set the value to your own email address.

  4. Start a build.

If all went well, you should see the changes in your repository in your Git provider. The new username and email address will be visible for all future commits you push from your builds to your Git provider.