My Jenkinsfile contains this stage:
stage('Deploy') {
steps {
script {
def rpmFiles = findFiles glob: "**/*.rpm"
def rpmFile = rpmFiles[0]
}
}
}
I want to use this to deploy an artifact to a server. How can I avoid the following error?
java.lang.NoSuchMethodError: No such DSL method 'findFiles' found among steps [...]
While this answer isn't directly fixing the issue of the original question - the plugin wasn't installed - search engines do redirect to this question, and I found the documentation a bit lacking. So I wanted to complement the answer a bit on how to use findFiles
.
As I wasn't completely satisfied by the documentation I looked at the source code and the FindFilesStep tests especially. There's one with this line in particular that showcase best how to use findFiles
:
def files = findFiles(glob: '**/*.txt', excludes: 'b/*.txt,**/aba/*.txt')
As a reminder the patterns are ant style patterns. For example I wanted a task that included every file and folders but the hidden folder .asccidoctor
, I wrote:
def docFiles
dir('build/docs/asciidoc/') {
docFiles = findFiles(glob: '**', excludes: '**/.asciidoctor/**')
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With