英文:
Azure App Service deploy of Spring Boot app not working from Jenkins
问题
以下是您提供的内容的翻译部分:
我有一个在Azure App Service上运行的Spring Boot应用程序。我可以使用Maven插件部署它,但无法使用Jenkins部署。奇怪的是,以前已经从Jenkins部署成功过。
使用Maven部署(使用mvn azure-webapp:deploy),我看到类似以下的输出:
[INFO] Auth Type : AZURE_CLI,Auth Files : [/Users/wdb/.azure/azureProfile.json, /Users/wdb/.azure/accessTokens.json]
[INFO] [Correlation ID: ab463b1c-xxxx-xxxx-xxxx-xxxxxxxxxxxx] Instance discovery was successful
[INFO] Subscription : MY_SUBSCRIPTION(797bdef0-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
[INFO] Updating App Service Plan...
[INFO] Updating target Web App...
[INFO] Successfully updated Web App.
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource to /Users/wdb/Projects/my-project/target/azure-webapp/my-project-backend-staging-80a97da7-6abf-49f4-9f4f-df92b8d38e20
[INFO] Trying to deploy artifact to my-project-backend-staging...
[INFO] Renaming /Users/wdb/Projects/my-project/target/azure-webapp/my-project-backend-staging-80a97da7-6abf-49f4-9f4f-df92b8d38e20/my-project-backend-staging-0.0.1-SNAPSHOT.jar to app.jar
[INFO] Deploying the zip package my-project-backend-staging-80a97da7-6abf-49f4-9f4f-df92b8d38e204401718728513612670.zip...
[INFO] Successfully deployed the artifact to https://my-project-backend-staging.azurewebsites.net
我在我的Jenkinsfile中使用了这个(使用Azure App Service Jenkins插件):
dir('target') {
sh '''
cp my-project-backend-*.jar app.jar
'''
azureWebAppPublish azureCredentialsId: 'JenkinsMyProjectBackendServicePrincipal',
resourceGroup: 'MYPROJECT-BACKEND',
appName: 'myproject-backend',
filePath: "app.jar"
}
当构建运行时,日志中会显示类似以下内容:
hudson.plugins.git.GitException: 命令 "git fetch --tags --force --progress -- https://myproject-backend-staging.scm.azurewebsites.net:443/myproject-backend-staging.git +refs/heads/*:refs/remotes/origin/*" 返回状态码 128:
stdout:
stderr: remote: Counting objects: 74, done.
remote: Compressing objects: 2% (1/48)
remote: Compressing objects: 4% (2/48)
remote: Compressing objects: 6% (3/48)
remote: Compressing objects: 8% (4/48)
remote: Compressing objects: 10% (5/48)
remote: .
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:802)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:161)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:154)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:375)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:73)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
英文:
I have a Spring Boot application running as an Azure App Service. I can deploy it using the Maven plugin, but not from Jenkins. The strange thing is that it has already worked from Jenkins before.
When deploying with Maven (using mvn azure-webapp:deploy), I see something like:
[INFO] Auth Type : AZURE_CLI, Auth Files : [/Users/wdb/.azure/azureProfile.json, /Users/wdb/.azure/accessTokens.json]
[INFO] [Correlation ID: ab463b1c-xxxx-xxxx-xxxx-xxxxxxxxxxxx] Instance discovery was successful
[INFO] Subscription : MY_SUBSCRIPTION(797bdef0-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
[INFO] Updating App Service Plan...
[INFO] Updating target Web App...
[INFO] Successfully updated Web App.
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource to /Users/wdb/Projects/my-project/target/azure-webapp/my-project-backend-staging-80a97da7-6abf-49f4-9f4f-df92b8d38e20
[INFO] Trying to deploy artifact to my-project-backend-staging...
[INFO] Renaming /Users/wdb/Projects/my-project/target/azure-webapp/my-project-backend-staging-80a97da7-6abf-49f4-9f4f-df92b8d38e20/my-project-backend-staging-0.0.1-SNAPSHOT.jar to app.jar
[INFO] Deploying the zip package my-project-backend-staging-80a97da7-6abf-49f4-9f4f-df92b8d38e204401718728513612670.zip...
[INFO] Successfully deployed the artifact to https://my-project-backend-staging.azurewebsites.net
I have this in my Jenkinsfile (using the Azure App Service Jenkins Plugin):
dir('target') {
sh '''
cp my-project-backend-*.jar app.jar
'''
azureWebAppPublish azureCredentialsId: 'JenkinsMyProjectBackendServicePrincipal',
resourceGroup: 'MYPROJECT-BACKEND',
appName: 'myproject-backend',
filePath: "app.jar"
}
When the build is run, I see this in the logging:
hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- https://myproject-backend-staging.scm.azurewebsites.net:443/myproject-backend-staging.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Counting objects: 74, done.
remote: Compressing objects: 2% (1/48)
remote: Compressing objects: 4% (2/48)
remote: Compressing objects: 6% (3/48)
remote: Compressing objects: 8% (4/48)
remote: Compressing objects: 10% (5/48)
remote: .
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:802)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:161)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:154)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:375)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:73)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
答案1
得分: 1
问题是Azure Jenkins插件检查linuxFxVersion是否包含jre。但如果您使用的是Java 11,情况并非如此(值类似于JAVA|11-java11)。因此,它错误地认为这不是一个要部署到的Java平台。
我已经修复了这个问题,并在https://github.com/jenkinsci/azure-app-service-plugin/pull/63上提交了一个PR。
我目前正在使用我本地构建的版本,直到他们采纳了这个PR。
除此之外,我还需要创建一个zip文件才能使它完全工作:
dir('target') {
sh '''
cp my-project-backend-*.jar app.jar
'''
zip zipFile: 'app.zip', glob: 'app.jar'
azureWebAppPublish azureCredentialsId: 'JenkinsMyProjectBackendServicePrincipal',
resourceGroup: 'MYPROJECT-BACKEND',
appName: 'my-project-backend-staging',
filePath: "app.zip"
}
英文:
The problem is that the Azure Jenkins plugin checks the linuxFxVersion to contain jre. But if you use Java 11, this is not the case (The value is something like JAVA|11-java11). Because of that, it wrongly thinks that it is not a Java platform to deploy to.
I fixed the issue and opened a PR at https://github.com/jenkinsci/azure-app-service-plugin/pull/63.
I am currently using my locally build version until they pick up this PR.
Next to that, I also had to create a zip file to make it fully work:
dir('target') {
sh '''
cp my-project-backend-*.jar app.jar
'''
zip zipFile: 'app.zip', glob: 'app.jar'
azureWebAppPublish azureCredentialsId: 'JenkinsMyProjectBackendServicePrincipal',
resourceGroup: 'MYPROJECT-BACKEND',
appName: 'my-project-backend-staging',
filePath: "app.zip"
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论