[英]Azure App Service deploy of Spring Boot app not working from Jenkins
我有一個作為 Azure 應用服務運行的 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: 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
問題在於 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"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.