Linux alternative to .git-credentials

oliver's Avatar

oliver

19 Mar, 2018 10:59 AM

Hi.

I am using this line to authenticate with the github repository (so that I can push changes):

- ps: Add-Content "$env:USERPROFILE.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`n"

This fails on the ubuntu image with:

Add-Content : Access to the path '/.git-credentials' is denied.

Do you have a suggestion how I could do this differently?

Thanks

  1. 1 Posted by oliver on 20 Mar, 2018 06:16 PM

    oliver's Avatar

    bump

  2. Support Staff 2 Posted by Wasa Pleshakov on 20 Mar, 2018 09:32 PM

    Wasa Pleshakov's Avatar

    There is no USERPROFILE variable in ubuntu that is why it tries to write file in the root of FS. Please use Home variable instead which is set both in linux and windows (Note, it does not have trailing slash). I suggest to use Join-Path for multiplatform scripts when you need to construct path to file:

    Join-Path $Home ".git-credentials"
    

    In ubuntu image you have to configure git to use .git-credentials file as credential Storage:

    git config --global credential.helper "store --file ~/.git-credentials"
    
    For Git Credential Storage please read https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage

    Also you may get access to your github repos by ssh: https://help.github.com/articles/connecting-to-github-with-ssh/

  3. 3 Posted by oliver on 21 Mar, 2018 02:42 PM

    oliver's Avatar

    yeap.. that did it..
    I should have noticed that. sorry.

    about the ssh: how would I deploy the certificates to the CI without making them available in the public repo?

  4. Support Staff 4 Posted by Wasa Pleshakov on 21 Mar, 2018 08:14 PM

    Wasa Pleshakov's Avatar

    Oliver,
    Do you mean private keys for ssh?
    Any way you can store sensitive data encrypted in Secure Variables (https://www.appveyor.com/docs/build-configuration/#secure-variables) and echo that data to files you need during install, build or test phase.

  5. 5 Posted by oliver on 21 Mar, 2018 10:54 PM

    oliver's Avatar

    ok... I guess there is something I didn't understand yet.
    Because I was under the impression the private key would be a file

  6. Support Staff 6 Posted by Ilya Finkelshte... on 21 Mar, 2018 11:04 PM

    Ilya Finkelshteyn's Avatar

    Here is Windows sample. Do you believe you can adapt it for Linux? And of yes, can you share how you made it work?

    Meanwhile I filed this issue but Base64 approach should work well too.

  7. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:27 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac