[RESOLVE] Push to bitbucket mercurial repo

botella.arnaud's Avatar

botella.arnaud

23 Nov, 2016 08:13 PM

I have a remote bitbucket mercurial repository on which I would like to push if the appveyor build succeed.

I understand how the keyword on_success works but not how to push on this bitbucket repository. I read some thread about login into a git repository and I would like to the same for mercurial repository.

Thank you for your help.

  1. 1 Posted by Ilya Finkelshte... on 24 Nov, 2016 01:41 AM

    Ilya Finkelshteyn's Avatar

    Hello,

    Here is what I tried on my lab and it seems to work:

    1. Remove Appveyor deployment key from https://bitbucket.org///admin/deploy-keys/
    2. Copy this key content from https://ci.appveyor.com/project///settings > SSH public key
    3. Add new key in https://bitbucket.org/account/user//ssh-keys/ and paste content copied before

    Points 1 – 3 needed to allow appveyor to push, as by default SSH key used is deployment key which has read-only permissions.

    1. Add the following to appveyor.yml (you can do on_success if you need):
    on_finish:
    # add username to mercurial settings
      - echo [ui] > C:\Users\appveyor\mercurial.ini
      - echo username = <your_account_name> >> C:\Users\appveyor\mercurial.ini
    
    # create sample change, commit commit and push. Note that [skip ci] in commit message to avoid recurcive builds start
      - echo a > myfile2.txt
      - hg status
      - hg add myfile2.txt
      - hg status
      - hg commit -m "Added one file [skip ci]"
      - hg status
      - hg push
    

    This assumes that is the same on BitBucket and AppVeyor. Please replace accordingly if it different.

    --ilya.

  2. 2 Posted by botella.arnaud on 24 Nov, 2016 08:02 AM

    botella.arnaud's Avatar

    Thank you for your answer.

    I understand what you propose. However, I do not find the SSH public key in appveyor... My project is public, so it seems Appveyor do not need a ssh key to clone the repository.

    Where can I find or create one for Appveyor? Maybe I can create a public and private key and copy them during the install part of the build.

  3. 3 Posted by Ilya Finkelshte... on 24 Nov, 2016 11:01 AM

    Ilya Finkelshteyn's Avatar

    This is what works for me with public project. I took hint from here

    environment:
      bbpwd:
        secure: <encrypted_bitBucket_password>
     
    on_finish:  
      - echo [ui] > C:\Users\appveyor\mercurial.ini
      
    # note that I was needed to use email I use for BB login, not name I see in BB repo URL
      - echo username = <bitBucket_account_name> >> C:\Users\appveyor\mercurial.ini 
    
      - echo [auth] >> C:\Users\appveyor\mercurial.ini
      - echo bb.prefix = https://bitbucket.org >> C:\Users\appveyor\mercurial.ini
      - echo bb.username = <bitBucket_account_name> >> C:\Users\appveyor\mercurial.ini
      - echo bb.password = %bbpwd% >> C:\Users\appveyor\mercurial.ini
      
      - echo a > myfile.txt
      - hg status
      - hg add myfile.txt
      - hg status
      - hg commit -m "Added one file [skip ci]"
      - hg status
      - hg push
    

    --ilya.

  4. 4 Posted by botella.arnaud on 25 Nov, 2016 07:02 AM

    botella.arnaud's Avatar

    It works! Thank you! :)

  5. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:09 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