我正在开发Jenkinsfile管道以在Jboss EAP中部署application(war),但是尝试在jboss中添加和启用war构件时遇到错误。我在Google上搜索了很多,但是没有找到解决方案。
我将在此处发布Jenkinsfile中定义的所有步骤,以澄清问题;
在具有“ **”的行中,我试图执行添加操作并在服务器上启用工件,但出现错误:
部署Test-2.5.3-SNAPSHOT.war失败,错误为:JBAS014807: 找不到管理资源'[(“ deployment” =>“ Test-2.5.3-SNAPSHOT.war”)]'。
我不知道可以解决这个问题。
def deploy(deploymentFileName, oldWarFile, workspace) {
def hostname = 'myHost'
def managementPort = 'myPort'
def user = 'test'
def userPass = 'test'
def deploymentNameWoPath = determineFileName(deploymentFileName)
def oldDeployFile = oldWarFile+".war"
def relativePathDeployFile = workspace +"/"+ deploymentFileName
// undeploy old war if present
echo "Undeploying ${deploymentFileName} to ${hostname}:${managementPort} ..."
sh "curl --digest -D - http://${user}:${userPass}@${hostname}:${managementPort}/management --header \"Content-Type: application/json\" -d '{\"operation\":\"undeploy\", \"address\":[{\"server-group\":\"AppsVR\"},{\"deployment\":\"${oldDeployFile}\"}]}'"
// step 1: upload archive
echo "Uploading ${deploymentFileName} to ${hostname}:${managementPort} ..."
sh "curl -F \"file=@${relativePathDeployFile}\" --digest http://${user}:${userPass}@${hostname}:${managementPort}/management/add-content > result.txt"
// step 2: deploy the archive
// read result from step 1
def uploadResult = readFile 'result.txt'
def bytesValue = extractByteValue(uploadResult)
if (bytesValue != null) {
echo "Deploying ${deploymentFileName} to ${hostname}:${managementPort} ..."
sh "**curl -S -H \"Content-Type: application/json\" -d '{\"content\":[{\"hash\": {\"BYTES_VALUE\" : \"${bytesValue}\"}}, \"url\":{}], \"address\": [{\"server-group\":\"AppsVR\"}, {\"deployment\":\"${deploymentNameWoPath}\"}], \"operation\":\"add\", \"enabled\":\"true\"}' --digest http://${user}:${userPass}@${hostname}:${managementPort}/management** > result2.txt"
def deployResult = readFile 'result2.txt'
def failure = hasFailure(deployResult)
if (failure != null) {
//deploy old war
sh "curl --digest -D - http://${user}:${userPass}@${hostname}:${managementPort}/management --header \"Content-Type: application/json\" -d '{\"operation\":\"deploy\", \"address\":[{\"server-group\":\"AppsVR\"},{\"deployment\":\"${oldDeployFile}\"}]}'"
error "Deployment of ${deploymentNameWoPath} failed with error: ${failure}"
}else{
sh "curl --digest -D - http://${user}:${userPass}@${hostname}:${managementPort}/management --header \"Content-Type: application/json\" -d '{\"operation\":\"remove\", \"address\":[{\"server-group\":\"AppsVR\"},{\"deployment\":\"${oldDeployFile}\"}]}'"
}
} else {
// fail build as deployment was not successfull
error "Upload of ${deploymentFileName} failed"
}
}