我们有一个Jenkins Pipeline作业设置,可以使用MSDeploy部署到我们的开发环境。我们已将一个常规文件检入源代码管理中,该文件运行多个不同应用程序的部署。然后,每个应用程序都下载并调用此文件。当MSDeploy遇到诸如错误代码:ERROR_USER_NOT_ADMIN的错误时,作业将按预期失败。如果有人不满SetParameters.xml文件中的“ IIS Web应用程序名称”,则可以在Jenkins日志
中看到错误。15:55:36 Error Code: ERROR_SITE_DOES_NOT_EXIST
15:55:36 More Information: Site 'dev.mysite.com1' does not exist. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SITE_DOES_NOT_EXIST.
15:55:36 Error count: 1.
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timestamps
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
但是工作仍然成功存在。
摘录自Pipeline Job Groovy:
Stages = load "DeployTo_Test.Groovy"
Stages.Deploy(DROP_FOLDER, PROJECT_NAME, VER_DEPLOY_TO)
DeployTo_Test.Groovy的摘录
def Deploy(DROP_FOLDER, PROJECT_NAME, VER_DEPLOYMENT_LOCATION) {
...SetSomeValues
bat "pushd ${COMMAND_LOC_TO_RUN} && ${PROJECT_NAME}.deploy.cmd /Y /M:${deploymentMachines[i]} /U:%DeployUsername% /P:%DeployPassword% -setParamFile:%workspace%\\${SetParamFile}"
}
来自另一个导致作业失败的MSDeploy错误的日志
16:16:48 Error Code: ERROR_USER_NOT_ADMIN
16:16:48 More Information: Connected to 'myMachine.com' using the Web Deployment Agent Service, but could not authorize. Make sure you are an administrator on 'myMachine.com'. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_ADMIN.
16:16:48 Error: The remote server returned an error: (401) Unauthorized.
16:16:48 Error count: 1.
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timestamps
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -1
Finished: FAILURE
为什么Jenkins \ MSDeloy bat命令成功退出并出现ERROR_SITE_DOES_NOT_EXIST,如何使它像其他情况一样在此错误上失败?