我有非常简单的管道,像这样:
pipeline {
agent any
stages {
stage('Build Automation') {
steps {
sh '''
echo "BUILD NUMBER: ${BUILD_NUMBER}"
cd myproject
mvn clean package
'''
}
}
stage('Prepare artifacts') {
steps {
sh '''
cd myproject/target
ls
archiveArtifacts 'myproject/target/*'
'''
}
}
}
}
Build Automation
步骤成功完成,但我总是收到`archiveArtifacts':
[myproject-automation_master-FALMJHZX7ZH5GMLQBBOYFJQRFPX4WIHQXBH2YXEQDL4TDAMTRYTQ] Running shell script
+ cd myproject/target
+ ls
classes
generated-sources
generated-test-sources
myapp
myapp.war
maven-archiver
maven-status
test-classes
+ archiveArtifacts myproject/target/*
/var/jenkins_home/workspace/myproject-automation_master-FALMJHZX7ZH5GMLQBBOYFJQRFPX4WIHQXBH2YXEQDL4TDAMTRYTQ@tmp/durable-6a43d2f0/script.sh: 5: /var/jenkins_home/workspacemyproject-automation_master-FALMJHZX7ZH5GMLQBBOYFJQRFPX4WIHQXBH2YXEQDL4TDAMTRYTQ@tmp/durable-6a43d2f0/script.sh: archiveArtifacts: not found
我已添加ls
以查看target
文件夹中是否有任何文件,因此它们存在,但archiveArtifacts始终返回未找到。我尝试了各种模式,例如*.war
,**/target/*.war
,但没有运气。
可能出现什么问题?
答案 0 :(得分:3)
您需要从sh步骤中删除archiveArtifacts步骤。它现在的方式是作为shell脚本的一部分运行并解释为命令。
steps {
sh '''
cd myproject/target
ls
'''
archiveArtifacts 'myproject/target/*'
}
上述情况应该有效。