As a part of this automation thing I am doing, I am required to clone a repo as it has a json file that I will need to use for automation. I have imported posh-git
but I am unable to run git clone <url>
in it. Here is the error: git : The term 'git' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Obviously, I have added my account in the Source Control. So, I have done
$SourceControl = Get-AzureRmAutomationSourceControl -AutomationAccountName $AutomationAccountName -Name testRepo -ResourceGroupName $ResourceGroupName
And then I am doing git clone $SourceControl.RepoUrl
And it fails with said error.
Any help is greatly appreciated.
You could not use the posh-git
module in the runbook, becasue there is no git installed in the runbook, so you will get the error.
See the option 3 in the Prerequisites:
Git must be installed and available via the PATH environment variable. Check that git is accessible from PowerShell by executing git --version from PowerShell. If git is not recognized as the name of a command, verify that you have Git installed. If not, install Git from https://git-scm.com. If you have Git installed, make sure the path to git is in your PATH environment variable.
Your option is to write all your script in the repository, configure the source control and sync the job, refer to the link.
Or if you just want to get the .ps1 file, you could store it as a blob in the storage account, then use the Get-AzStorageBlobContent
to get it.