How to push a commit back to the same repository as part of the CircleCI job

 

You may have a use case for creating a new commit and pushing it to the same repository as part of your CircleCI job.

Configuration Steps

Here is how you can configure your CircleCI project to enable the above-mentioned use case.

1) Decide if you wish to configure the project with a user key generated by CircleCI or a manually-created read-write deployment key

1a) If you wish to use a user key, simply visit https://circleci.com/:vcs-type/:org-name/:project-name/edit#checkout and click on the "Authorize with GitHub" button.

1b) If you wish to use a read-write deployment key, follow the steps here to create it and configure the project so that the key has write permissions for it: https://circleci.com/docs/2.0/gh-bb-integration/#creating-a-github-user-key or https://circleci.com/docs/2.0/gh-bb-integration/#creating-a-bitbucket-user-key for Bitbucket users

 

Common Issues:

1) "*** Please tell me who you are." error message upon running "git commit"

In your CircleCI configuration file (config.yml), you might have to add commands to configure an email and user name with `git config` prior to running `git commit`, e.g.

git config user.email "username@mydomain.com"
git config user.name "My Name"


2) Running git push results in "ERROR: The key you are authenticating with has been marked as read only."

The deploy key that the project is configured with, by default when you add a project on CircleCI, only has read access, so a key with write permissions needs to be configured to be used, to avoid the above error message. Please ensure that a user key or a read-write deployment key has been configured for the project (See "Configuration Steps" above).

If you are using a read-write deployment key, please add an add_ssh_keys step to your configuration. The fingerprints value should match what is shown on https://circleci.com/:vcs-type/:org-name/:project-name/edit#ssh

 

3) How to stop your generated commits from triggering new builds

To prevent a commit from triggering a new build, add "[skip ci]" to the commit message. For more details, see: https://circleci.com/docs/2.0/skip-build/#skipping-a-build

 

Was this article helpful?
2 out of 6 found this helpful

Comments

0 comments

Please sign in to leave a comment.