Created
January 19, 2018 19:36
-
-
Save rfennell/2cc36232158518b3b36866bfd321644d to your computer and use it in GitHub Desktop.
PowerShell script add a commit to the current repo for use inside a VSTS CI/CD process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
$file = "readme.md", | |
$text = "Automated edit", | |
$wi = "#13 #14" | |
) | |
"Set config" | |
git config --global user.email "[email protected]" # any values will do, if missing commit will fail | |
git config --global user.name "Build user" | |
"Select a branch" | |
git checkout master 2>&1 | write-host # need the stderr redirect as some git command line send none error output here | |
"Update the local repo" | |
git pull 2>&1 | write-host | |
"Status at start" | |
git status 2>&1 | write-host | |
"Update the file $file" | |
Add-Content -Path $file -Value "$text - $(Get-Date)" | |
"Status prior to stage" | |
git status 2>&1 | write-host | |
"Stage the file" | |
git add $file 2>&1 | write-host | |
"Status prior to commit" | |
git status 2>&1 | write-host | |
"Commit the file" | |
git commit -m "Automated Repo Update $wi" 2>&1 | write-host | |
"Status prior to push" | |
git status 2>&1 | write-host | |
"Push the change" | |
git push 2>&1 | write-host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment