Search code examples
visual-studio-app-center

Is there a way to push git tag from appcenter build script?


Is there a way to push git tag from appcenter build script? I am trying to push git tags from appcenter's build script -

  git tag  'test'
  git push origin 'test'

But I keep getting the following error -

fatal: could not read Password for {username}: terminal prompts disabled

I was expecting to work it out with ssh key or password prompts but nothing worked. Is there something similar to this for appcenter -

https://github.com/semantic-release/semantic-release/blob/master/docs/03-recipes/git-auth-ssh-keys.md

Please let me know if I can clarify further.


Solution

  • We went over this over support, but thought would be good to share here too.

    If the repository is public, it should just work. But if it is private, here's what you can do (use Bitbucket as an example):

    1. Create a personal access token (Bitbucket calls it app password) in your Bitbucket account. Make sure the token has permission to write to your repository
    2. Add the token as a secret variable in your branch configuration
    3. In post build script, before pushing the tag, change remote url to include the token, e.g.: git remote set-url --push origin https://dpan:@bitbucket.org/dpan/hn.git
    4. Queue a new build and now pushing a tag should work!