git commit to another repo is ignored

blaeser's Avatar


25 Jul, 2018 10:02 AM

Hi all,

I am using Appveyor to commit a file back to another GitHub repository. Strangely, the "git commit" command is being ignored when I use some environment variables in the commit message. Here is a small example of what I am doing:

  # this is all taken from
  - git config --global credential.helper store
  - ps: Add-Content "$HOME\.git-credentials" "https://$($env:access_token)`n"
  - git config --global "[email blocked]"
  - git config --global "Appveyor"
  - git clone -b some_branch --single-branch --depth 1
  - cd SomeRepo
  # copy the file that we want to commit
  - copy ..\somefile.xml .
  - git add . *.xml
  # now comes strange behavior: the following line is simply ignored. It does not show up in the log. Why? Is it the environment variables?
  - git commit -a --allow-empty -m "Appveyor commit: $($env:APPVEYOR_BUILD_NUMBER), $($env:APPVEYOR_BUILD_VERSION) based on $($env:APPVEYOR_REPO_COMMIT)"
  # this here actually works, but it lacks the important info, where the build is coming from
  - git commit -a --allow-empty -m "Appveyor commit"
  - git push

I also tried different variants of the environment variables in the commit message, such as $env:APPVEYOR_BUILD_NUMBER (same effect), $APPVEYOR_BUILD_NUMBER (same effect), %APPVEYOR_BUILD_NUMBER% (throws an error).


  1. Support Staff 1 Posted by Ilya Finkelshte... on 25 Jul, 2018 10:39 AM

    Ilya Finkelshteyn's Avatar

    I assume you are running Windows build (not Linux one). So you call git commit in CMD mode (no prefix defaults to CMD on Windows builds). However environment variables are in PowerShell style. %APPVEYOR_BUILD_NUMBER% is correct option. Look at error it throws deeper, but first start using both variables (%APPVEYOR_BUILD_VERSION% too) in CMD style.

  2. 2 Posted by blaeser on 25 Jul, 2018 11:52 AM

    blaeser's Avatar

    Thanks for the response, yes, it is a Windows build. However if I use the line:

      - git commit -a --allow-empty -m "Appveyor commit: %APPVEYOR_BUILD_NUMBER%, %APPVEYOR_BUILD_VERSION% based on %APPVEYOR_REPO_COMMIT%"

    I am getting the following error:

    Error parsing appveyor.yml: (Line: 52, Col: 43, Idx: 1662) - (Line: 52, Col: 44, Idx: 1663): While scanning for the next token, find character that cannot start any token.
  3. Support Staff 3 Posted by Ilya Finkelshte... on 25 Jul, 2018 11:56 AM

    Ilya Finkelshteyn's Avatar

    Wrap the command in single quotes, e.g.

    - 'git commit -a --allow-empty -m "Appveyor commit: %APPVEYOR_BUILD_NUMBER%, %APPVEYOR_BUILD_VERSION% based on %APPVEYOR_REPO_COMMIT%"'

    You can always use UI and Export YAML button if you are not sure in syntax.

  4. Ilya Finkelshteyn closed this discussion on 24 Sep, 2018 09:00 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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

21 Aug, 2019 11:06 PM
21 Aug, 2019 02:08 PM
21 Aug, 2019 01:37 PM
21 Aug, 2019 10:21 AM
21 Aug, 2019 09:10 AM


21 Aug, 2019 05:56 AM
21 Aug, 2019 03:08 AM
20 Aug, 2019 11:33 PM
20 Aug, 2019 08:07 PM
20 Aug, 2019 05:50 PM
20 Aug, 2019 12:35 PM