Running shell in its own thread does nothing

Dear all,
asking for small help to deal with concurrency in Groovy.

I’m executing the following function:

def sendFiles(host, repo, dist, files) {
 
  def threads = []
  files.each { file->
      def th = Thread.start {
         pushFileViaCurlTest(repo, dist, file)
      } // end th
      threads << th
      println "putting thread: ${th} in threads list"
  }  
 
  // wait all threads
  threads.each { it.join() }
}

def pushFileViaCurlTest(repo, dist, file) {
  def host = 'https://example.com/'

  def curl_status = sh(
    script: "curl -i --fail -XPOST -F 'filename=@${file}' '${host}/?repo=${repo}&dis=${dist}' ",
    returnStdout: true,
  )
  print curl_status
}

But I don’t see any logs in my web server…? (web server works fine).
Even I change shell command to println - I don’t see any output :confused:
it looks like sh hasn’t been executed, could you please tell me how to debug / fix it?

Appreciate any suggestion and documentation to read.

Thank you,
Pasha

So not knowing the answer, I will say Jenkinsfile are not groovy, they are groovy like. Anything you do in Jenkinsfile runs on the controller (except specific statements like sh) so the recommendation is to keep jenkinsfile logic to control flow and do any heavy lifting in an external script (bash, external groovy, etc).

My $0.02, hopefuly someone else will know the answer though

Thank you for the input, Gavin,

just for the context - my groovy code lives in the shared library and Jenkinsfile imports it