Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label Git repository in AppVeyor build using environment variable

I am trying to label a repository after a successful build in AppVeyor. I have read the following resources:

  • Environment variables
  • appveyor.yml reference
  • Pushing to remote Git repository from a build

But I don't know how to substitute in an AppVeyor environment variable. Here is the Yaml that I am using:

on_success:
  - git config --global credential.helper store
  - ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):[email protected]`n"
  - git tag -a release/$($env:APPVEYOR_BUILD_VERSION)
  - git push origin release/$($env:APPVEYOR_BUILD_VERSION)

This results in the following error in the AppVeyor build log

git config --global credential.helper store
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):[email protected]`n"
git tag -a release/$($env:APPVEYOR_BUILD_VERSION)
fatal: 'release/$($env:APPVEYOR_BUILD_VERSION)' is not a valid tag name.
Command exited with code 128

Given that the powershell Add-Content line is supposed to work as per the example how are you supposed to substitute variables into the git commands?

like image 593
Bronumski Avatar asked May 21 '15 23:05

Bronumski


People also ask

How do I set Git environment variables in Linux?

In Linux, you can set and unset user-specific environment variables. You must add and edit the “. bashrc” file in the home directory to export or change the environment variable. Then, to make the changes take effect, source the file.

What is environment variable in Git?

Git always runs inside a bash shell, and uses a number of shell environment variables to determine how it behaves. Occasionally, it comes in handy to know what these are, and how they can be used to make Git behave the way you want it to.

What is AppVeyor Yml file?

appveyor. yml is a project configuration file in YAML format that should be placed in the root of your repository.


1 Answers

Should be:

- git tag -a release/%APPVEYOR_BUILD_VERSION%
- git push origin release/%APPVEYOR_BUILD_VERSION%
like image 152
Feodor Fitsner Avatar answered Sep 23 '22 01:09

Feodor Fitsner