你好,我是詹金斯的新手,正在遇到这个问题。我在Windows Azure中使用詹金斯
- MVN清洁包/var/lib/jenkins/workspace/vcc@tmp/durable-b5407f14/script.sh:2: /var/lib/jenkins/workspace/vcc@tmp/durable-b5407f14/script.sh:mvn: 找不到。
Jenkins文件:
node {
stage('init') {
checkout scm
}
stage('build') {
sh '''
mvn clean package
cd target
cp ../src/main/resources/web.config web.config
cp todo-app-java-on-azure-1.0-SNAPSHOT.jar app.jar
zip todo.zip app.jar web.config
'''
}
stage('deploy') {
azureWebAppPublish azureCredentialsId: env.AZURE_CRED_ID,
resourceGroup: env.RES_GROUP, appName: env.WEB_APP, filePath: "**/todo.zip"
}
}
任何人都可以帮助我如何解决此mvn问题。
P.S我正在关注本教程 https://docs.microsoft.com/en-us/azure/jenkins/tutorial-jenkins-deploy-web-app-azure-app-service
答案 0 :(得分:0)
您可以尝试将Maven工具添加到管道中:
tools {
maven 'M3'
}
stages {
stage('init') {
checkout scm
}
stage('build') {
sh '''
mvn clean package
cd target
cp ../src/main/resources/web.config web.config
cp todo-app-java-on-azure-1.0-SNAPSHOT.jar app.jar
zip todo.zip app.jar web.config
'''
}
stage('deploy') {
azureWebAppPublish azureCredentialsId: env.AZURE_CRED_ID,
resourceGroup: env.RES_GROUP, appName: env.WEB_APP, filePath: "**/todo.zip"
}
}
答案 1 :(得分:0)
在构建阶段,我在sh命令之前添加以下行:def mvnHome = tool name: 'Apache Maven 3.6.0', type: 'maven'
而不是mvn,您应该使用${mvnHome}/bin/mvn
感谢this youtube film来帮助我。
pipeline{
stage('com'){
def mvnHome = tool name: 'Apache Maven 3.6.0', type: 'maven'
sh "${mvnHome}/bin/mvn -B -DskipTests clean package"
}
}
答案 2 :(得分:0)