Michael
Michael

Reputation: 1

Fail to pull Azure DevOps repository called by T-SQL

I am trying to build some automation which will compare my SQL Server databases against git repository, stored on Azure DevOps. There is a simple ps script, stored in a file, which works like a charm when I call it from Powershell command line:

D:\SSDT\Production\SQL02> D:\SSDT\ps_scripts\UpdRepo.ps1 warning: redirecting to https://someaddress.visualstudio.com/someaddress/_git/anotherurl/ Already up to date.

Now I want to call that ps file from a SQL Stored Procedure, using:

exec master..xp_cmdshell 'powershell.exe "E:\SSDT\ps_scripts\UpdRepo.ps1"'

And all I get is:

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. At E:\SSDT\ps_scripts\UpdRepo.ps1:2 char:1 git pull

CategoryInfo : ObjectNotFound: (git:String) [], CommandNotFoundException FullyQualifiedErrorId : CommandNotFoundException

NULL

I did add C:\Program Files\Git\bin
C:\Program Files\Git\cmd
to system environment variables but SQL Engine seems ignoring those

I tried different syntax but got the same error messages Tried to run script on SSMS and with SQL job

Any suggestion with how can I introduce git command to SQL engine or alternative way to call git pull command from SQL Server, or perhaps calling ps without SQL Engine try to parse it, will be appreciated! SQL Server 2019 Enterprise addition

Upvotes: 0

Views: 29

Answers (0)

Related Questions