Problem in Powershell with the --runtime command setting up Jenkins pipeline

安稳与你 提交于 2021-01-07 03:12:40

问题


I am trying to configure a Pipeline with Jenkins and deploying it to Azure. I am at the last step of a tutorial:

https://docs.microsoft.com/en-us/azure/jenkins/tutorial-jenkins-deploy-web-app-azure-app-service

This last step is as follows, i have to enter this in the Azure CLI:

az group create --name yourWebAppAzureResourceGroupName --location region
az appservice plan create --name appServicePlanName --resource-group rgname --is-linux
az webapp create --name webAppName --resource-group rgName --plan appServicePlanName --runtime "java|1.8|Tomcat|8.5"

The last command gives me the error:

'1.8' is not recognized as an internal or external command, operable program or batch file.

So I thought maybe Tomcat is not installed on my Azure VM, which is a Linux machine. So I used the next tutorial to install Tomcat:

https://www.howtoforge.com/tutorial/how-to-install-apache-tomcat-8-5-on-ubuntu-16-04/

After this I tried to do the --runtime command again, but I still get the same error. I have no idea how to fix this. I hope someone can help me with this problem.

I tried to check the webapp list-runtimes and I get this list:

"java|1.8|Tomcat|8.5" is in here. I've tried all of the versions, but it did not work.

EDIT: It works in the Azure Cloud Shell, but then there is another error:

Linux Runtime 'java|1.8|Tomcat|8.5' is not supported.Please invoke 'list-runtimes' to cross check

I have tried all the runtime versions, but still this error. I have also tried it with double quotes


回答1:


ok, i got it, that list is for windows webapp, not linux. for linux use:

az webapp list-runtimes --linux

so working solution:

az webapp create --name yourWebAppName --resource-group yourWebAppAzureResourceGroupName --plan yourLinuxAppServicePlanName --runtime "TOMCAT|8.5-jre8" 



回答2:


I bet you solved your problem already, but in case others find this and are using PowerShell to run Azure CLI commands. This is what worked for me.

The problem is in how PowerShell interprets the pipe, '|', character inside the --runtime parameter, when evaluating the whole line.

Add the --% to be beginning of the command to turn off PowerShell evaluation of expressions, as suggested in the code block here.

Note: this will also stop PowerShell from evaluating any variables inside the command. What you can do is move the --runtime to the end of the line to get around this problem, e.g. like this

az webapp create -g $rg -p $appPlanName -n $appName --deployment-local-git --% --runtime "DOTNETCORE|3.0"


来源:https://stackoverflow.com/questions/54863650/problem-in-powershell-with-the-runtime-command-setting-up-jenkins-pipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!