在windows vm上使用jenkins azure应用程序服务插件和管道在azure中部署.NET web应用程序时,找不到Git

在windows vm上使用jenkins azure应用程序服务插件和管道在azure中部署.NET web应用程序时,找不到Git,jenkins,jenkins-pipeline,azure-appservice,Jenkins,Jenkins Pipeline,Azure Appservice,我正在尝试使用Jenkins和Azure应用程序服务插件将.NET web应用程序部署为Azure中的应用程序服务。如果我使用自由风格的作业并将“发布azure应用程序”作为构建后操作,那么一切都正常工作,但我需要执行更复杂的任务,所以我需要使用管道。 管道是: stage('checkout') { git branch: 'develop', url: 'https://github.com/test.git', credentialsId: 'cred' } s

我正在尝试使用Jenkins和Azure应用程序服务插件将.NET web应用程序部署为Azure中的应用程序服务。如果我使用自由风格的作业并将“发布azure应用程序”作为构建后操作,那么一切都正常工作,但我需要执行更复杂的任务,所以我需要使用管道。 管道是:

stage('checkout') {  
      git branch: 'develop', url: 'https://github.com/test.git', credentialsId: 'cred'
    }  
stage('build and publish') {  
     bat "dotnet publish test/test.sln -c Release "  
}
stage('deploy') {  
        azureWebAppPublish ([
            appName: "appName", 
            azureCredentialsId: params.azure_cred_id, 
            publishType: "file", 
            resourceGroup: "resName", 
            sourceDirectory: "test/test/bin/Release/netcoreapp3.1/publish/"
        ])
还尝试添加

    environment {
        git: 'C:\\Program Files\\Git\\cmd\\git.exe'
    }
“签出”和“构建和发布”阶段工作正常,但在“部署”阶段我遇到以下错误:

Starting Azure Web App Deployment
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
Caused: java.io.IOException: Cannot run program "git" (in directory "c:\jenkins\workspace\test\.azure-deploy"): CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at hudson.Proc$LocalProc.<init>(Proc.java:252)
    at hudson.Proc$LocalProc.<init>(Proc.java:221)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
    at hudson.Launcher$ProcStarter.start(Launcher.java:508)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2443)
Caused: hudson.plugins.git.GitException: Error performing git command: git init c:\jenkins\workspace\test\.azure-deploy
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2457)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2380)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2376)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1923)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:995)
启动Azure Web应用程序部署
java.io.IOException:CreateProcess error=2,系统找不到指定的文件
在java.lang.ProcessImpl.create(本机方法)
位于java.lang.ProcessImpl。(未知源)
位于java.lang.ProcessImpl.start(未知源)
原因:java.io.IOException:无法运行程序“git”(在目录“c:\jenkins\workspace\test\.azure deploy”中):CreateProcess错误=2,系统找不到指定的文件
位于java.lang.ProcessBuilder.start(未知源)
在hudson.Proc$LocalProc.(Proc.java:252)
在hudson.Proc$LocalProc.(Proc.java:221)
位于hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
位于hudson.Launcher$ProcStarter.start(Launcher.java:508)
位于org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2443)
原因:hudson.plugins.git.git异常:执行git命令时出错:git init c:\jenkins\workspace\test\.azure部署
位于org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2457)
位于org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2380)
位于org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2376)
位于org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1923)
位于org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:995)
主要jenkins在linux上运行,但此作业在windows节点上执行。配置为:

C:\Program Files\Git\cmd也添加到VM上的环境变量中


我想我缺少了一些额外的配置。

看起来windows计算机中没有安装git。windows节点上安装了git。路径也添加到环境变量中。Azure应用程序服务插件似乎从Jenkins中的“全局配置设置”读取环境变量,而不是用windows节点配置(屏幕截图上的配置)覆盖它们。您确定git.exe驻留在您提到的路径中吗,如果没有,请验证它是否如本文所述位于AppData文件夹中。