Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload multiple files using s3upload in Jenkins pipeline

Can we upload multiple files (not entire folder) to S3 using s3Upload in Jenkins file?

I was trying to upload all rpm files (*.rpm) in the root directory to S3 using the s3Upload function.

like image 502
rashidcmb Avatar asked Sep 01 '25 18:09

rashidcmb


2 Answers

You can upload all the files with following command in one line.

  s3Upload(bucket:"my-bucket", path:'path/to/targetFolder/', includePathPattern:'**/*.svg', workingDir:'dist')

Further explaining, You can create own filtering based on following two possibilities;

1.Include all the files of a certain extention.

s3Upload(bucket:"my-bucket", path:'path/to/targetFolder/', includePathPattern:'**/*.svg', workingDir:'dist')

2.Include all the files except certain file extention.

s3Upload(bucket:"my-bucket", path:'path/to/targetFolder/', includePathPattern:'**/*', workingDir:'dist', excludePathPattern:'**/*.svg')

Reference: https://github.com/jenkinsci/pipeline-aws-plugin (Check under s3Upload)

like image 174
PasinduJay Avatar answered Sep 04 '25 07:09

PasinduJay


findFiles solved the issue. Below is the snippet used for the same.

files = findFiles(glob: '*.rpm')

  files.each { 
      println "RPM:  ${it}"
      withAWS(credentials: '****************'){
       s3Upload(file:"${it}", bucket:'rpm-repo', path:"${bucket_path}")
        }
    }
like image 42
rashidcmb Avatar answered Sep 04 '25 08:09

rashidcmb