spotless-changelog icon indicating copy to clipboard operation
spotless-changelog copied to clipboard

Document how to pass the necessary credentials to allow push to remote GIT repository

Open ghilainm opened this issue 3 years ago • 4 comments

Currently it is not clear how we should pass credentials (or what is the strategy) to configure push to remote git repository, could you please update documentation to clarify that point?

ghilainm avatar Jan 11 '22 11:01 ghilainm

Wow! Not sure how we missed that. If you aren't using SSH:

https://github.com/diffplug/spotless-changelog/blob/8884a8b4db09c30541d9282f3290c1703cb782da/spotless-changelog-lib/src/main/java/com/diffplug/spotless/changelog/GitActions.java#L177-L196

If you are using SSH:

https://github.com/diffplug/spotless-changelog/blob/8884a8b4db09c30541d9282f3290c1703cb782da/spotless-changelog-lib/src/main/java/com/diffplug/spotless/changelog/GitActions.java#L177-L196

Agreed we should document better.

nedtwigg avatar Jan 11 '22 20:01 nedtwigg

Thanks for your answer. In the mean time I figure out the issue on my side. The problem was when integrating it in gitlab ci. I had to change the branch which was cloned and the remote origin to use another user than the ci user.

This was not that easy to figure out that one, don’t how I could avoid this for the next one who wants to do that.

ghilainm avatar Jan 11 '22 20:01 ghilainm

How about if git errors looked like this:

### Expected the current branch to be `main` and to push to `origin` because
spotlessChangelog {
  remote 'origin'
  branch 'main'
...

### Actual current branch is: git rev-parse --abbrev-ref HEAD
develop
### Actual remote origin is: git remote show origin
* remote origin
  Fetch URL: https://github.com/diffplug/spotless-changelog
  Push  URL: https://github.com/diffplug/spotless-changelog
  HEAD branch: main
  Remote branches:
    main                                 tracked
    master                               tracked

### You might need to set the remote url with: git remote set-url --push origin https://blahblahblah

### You might need to set credentials with:
- user/pass using environment variables `GRGIT_USER` and `GRGIT_PASS`
- token using environment variable `gh_token`
- ssh using `ssh://` URL and possibly adding `-PsshStrictHostKeyChecking=no` to Gradle command line

### The specific error you hit was
<e.printStackTrace()>

Anything missing from the above which would have helped resolve your case?

nedtwigg avatar Jan 11 '22 21:01 nedtwigg

Seems good to me!

ghilainm avatar Jan 12 '22 15:01 ghilainm