Commit Tag to bitbucket

william.j.davis5's Avatar

william.j.davis5

13 Mar, 2015 05:28 PM

I have my builds setup to increment the MINOR revision when a commit is pushed to master and built. It uses the REST API to update the YAML file and everything is great.

Now I want to also tag this specific commit with the version number and push this back to bitbucket.

I saw some examples of folks doing this with Github, but not with Bitbucket (doesnt have personal access tokens :( ).

Any thoughts?

  1. Support Staff 1 Posted by Feodor Fitsner on 13 Mar, 2015 06:29 PM

    Feodor Fitsner's Avatar

    is it Git or Mercurial repo?

  2. 2 Posted by william.j.davis... on 14 Mar, 2015 03:03 PM

    william.j.davis5's Avatar

    Hey Feodor - its a Git repo, sorry for not being specific.

  3. Support Staff 3 Posted by Feodor Fitsner on 15 Mar, 2015 03:57 AM

    Feodor Fitsner's Avatar

    Then this guide is still applicable to you: http://www.appveyor.com/docs/how-to/git-push
    Just use username/password instead of personal access token.

  4. 4 Posted by william.j.davis... on 16 Mar, 2015 02:15 AM

    william.j.davis5's Avatar

    Thanks Feodor -

    I followed the tutorial - here is my resulting build success script: (the relevant portion)

    Add-AppveyorMessage -Message "Tagging Commit with release #"
            git config --global credential.helper store
            Add-Content "$env:USERPROFILE.git-credentials" "https://$($env:username):$($env:password)@bitbucket.org`n"
            git tag $major.$minor.$env:APPVEYOR_BUILD_NUMBER ($env:APPVEYOR_REPO_COMMIT).Substring(0, 8)
            git push origin --tags
    

    And the error:

    git : conq: repository access denied. access via a deployment key is read-only.
    At line:40 char:3
    +         git push origin --tags
    +         ~~~~~~~~~~~~~~~~~~~~~~
    

    Am I missing a step?
    I'm going to try and update the remote url and see if that fixes it.

  5. 5 Posted by william.j.davis... on 16 Mar, 2015 02:33 AM

    william.j.davis5's Avatar

    That was the key - once I update the remote to not use SSH it worked.

    It may be worthwhile to mention that in the howto article

    Thanks!

  6. Support Staff 6 Posted by Feodor Fitsner on 16 Mar, 2015 05:57 AM

    Feodor Fitsner's Avatar

    Yeah, thanks for the note - will update documentation.

  7. 7 Posted by william.j.davis... on 16 Mar, 2015 03:59 PM

    william.j.davis5's Avatar

    So it appears this is working correctly, but for some reason it is throwing an exception.

    Here is a snip showing the commit pushed correctly:

    Image Name

    And here is a snip showing the exception which causes the build to report as failed:

    Imgur

    And here is a snip showing the script

    Imgur

    I'm not sure why the build says it failed. Thank you!

  8. Support Staff 8 Posted by Feodor Fitsner on 16 Mar, 2015 04:06 PM

    Feodor Fitsner's Avatar

    It's git outputting to StdErr what treated by PowerShell as exception. Add --quiet to git push command.

  9. 9 Posted by william.j.davis... on 16 Mar, 2015 04:44 PM

    william.j.davis5's Avatar

    Seriously great support here. You guys rock.

  10. 10 Posted by Brian Butterfie... on 31 Mar, 2015 06:38 PM

    Brian Butterfield's Avatar

    I am struggling with trying to configure a Bitbucket/Mercurial "push". I cannot seem to find any resources specific, but this post helpful and git specific.

    Thank you in advance for your help.

  11. Support Staff 11 Posted by Feodor Fitsner on 31 Mar, 2015 07:29 PM

    Feodor Fitsner's Avatar

    Basically, your goal is creating c:\users\appveyor\mercurial.ini file with mercurial repo URL and credentials: http://stackoverflow.com/questions/2584407/how-to-save-username-and...

  12. 12 Posted by Brian Butterfie... on 31 Mar, 2015 07:55 PM

    Brian Butterfield's Avatar

    1) Can I store the username and password in secure fields in environment variables and write them to mercurial.ini in the install script?

    2) If they are "secure" variables, will AppVeyor decrypt them when I use them in the install script? Nothing has stated this explicitly in my research so far.

    Thank you for your response.

  13. Support Staff 13 Posted by Feodor Fitsner on 31 Mar, 2015 08:27 PM

    Feodor Fitsner's Avatar

    1) Yes, you can.

    2) Yes, however secure variables are not decrypted during Pull Request builds. Other than that secure variables are just regular environment variables available in the build context. The primary purpose of secure variables is hiding sensitive information in appveyor.yml.

  14. 14 Posted by Brian Butterfie... on 03 Apr, 2015 03:41 PM

    Brian Butterfield's Avatar

    Sorry, but this did not work.

    I need a way to add my private SSH key I assume. Is there an additional file in mercurial somewhere I need to add in the case of appveyor?

  15. Support Staff 15 Posted by Feodor Fitsner on 03 Apr, 2015 03:51 PM

    Feodor Fitsner's Avatar

    mercurial.ini didn't work? Have you specified "destination" repository URL in hg push command? Because, if it was initially cloned with SSH default URL is not HTTPS.

  16. 16 Posted by Brian Butterfie... on 03 Apr, 2015 04:04 PM

    Brian Butterfield's Avatar

    Yes, Mercurial.ini did not work. Here is what I had.

    $fileContent = "[auth]"
    $fileContent += "bb.prefix = https://bitbucket.org/org/repo"
    $fileContent += "bb.username = xxxx"
    $fileContent += "bb.password = xxxx"
    Set-Content c:\users\appveyor\mercurial.ini $fileContent

    Are you saying it should be the following? Should the "prefix" be https or ssh? I will try the following.

    $fileContent = "[auth]"
    $fileContent += "bb.prefix = https://bitbucket.org/org/repo"
    $fileContent += "bb.username = xxxx"
    $fileContent += "bb.password = xxxx"
    $fileContent += "[paths]"
    $fileContent += "default = ssh://[email blocked]/org/repo"
    Set-Content c:\users\appveyor\mercurial.ini $fileContent

  17. Support Staff 17 Posted by Feodor Fitsner on 03 Apr, 2015 04:11 PM

    Feodor Fitsner's Avatar

    Shouldn't be there a "new line" symbol at the end of each line? kind of:

    $fileContent = "[auth]`n" 
    $fileContent += "bb.prefix = https://bitbucket.org/org/repo`n" 
    $fileContent += "bb.username = xxxx`n" 
    $fileContent += "bb.password = xxxx`n"
    

    Regarding repo URL I meant specifying https repo URL when pushing back:

    hg push <repo_url>
    
  18. 18 Posted by Brian Butterfie... on 03 Apr, 2015 04:18 PM

    Brian Butterfield's Avatar

    I can try that, but I do have it working by passing the username and password via the hg push <repo_url> in the following script.

    $url = "https://username:" + $env:BITBUCKET_PASSWORD + "@bitbucket.org/org/repo"

    hg push $url

    However, I would prefer not to store my password at all in the secure env variables.

  19. Support Staff 19 Posted by Feodor Fitsner on 03 Apr, 2015 04:22 PM

    Feodor Fitsner's Avatar

    Then how/where would you pass/store the password then?

    -Feodor

  20. 20 Posted by Brian Butterfie... on 03 Apr, 2015 05:10 PM

    Brian Butterfield's Avatar

    I should not need the password if I can associate the private SSH key somewhere in the Mercurial configuration. That is my current root question/issue.

  21. Support Staff 21 Posted by Feodor Fitsner on 03 Apr, 2015 06:24 PM

    Feodor Fitsner's Avatar

    Then it's the same location/technique as described here: http://www.appveyor.com/docs/how-to/private-git-sub-modules

  22. 22 Posted by merdan on 31 Dec, 2016 01:32 AM

    merdan's Avatar

    How to update the remote to not use SSH.
    I am using BitBucket wit Git repo

  23. Support Staff 23 Posted by Feodor Fitsner on 31 Dec, 2016 05:39 AM

    Feodor Fitsner's Avatar
  24. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:10 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