Commit Tag to bitbucket

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. is it Git or Mercurial repo?

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

  3. 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. 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. 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. Yeah, thanks for the note - will update documentation.

  7. 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. It's git outputting to StdErr what treated by PowerShell as exception. Add --quiet to git push command.

  9. Seriously great support here. You guys rock.

  10. 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. 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. 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. 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. 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. 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. 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. 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. 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. Then how/where would you pass/store the password then?

    -Feodor

  20. 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. Then it's the same location/technique as described here: http://www.appveyor.com/docs/how-to/private-git-sub-modules

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

  23. 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

Recent Discussions