I'm trying to deploy a .NET web app as an app service in Azure using Jenkins and Azure app service plugin. Everything is working fine if I use a free style job and 'publish an azure app' as a post-build action, but I need to perform more complex tasks so I need to use pipeline. The pipeline is:
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/"
])
Also tried adding
environment {
git: 'C:\\Program Files\\Git\\cmd\\git.exe'
}
The 'checkout' and 'build and publish' stages work fine, but on 'deploy' stage I get this error:
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)
The main jenkins is running on linux, but this job is executed on windows node. The configuration is: Jenkins node configuration
C:\Program Files\Git\cmd is also added in the Environment variables on the VM
I guess I'm missing some additional configuration.