multithreading inside cleanup step

15 views
Skip to first unread message

Omri Ben Yair

unread,
Jul 21, 2021, 9:54:27 AM7/21/21
to Jenkins Users
I am building to 2 different environments in the same pipeline and I want to make the cleanup for both environments in parallel.

As I understood, parallel does not work inside the post step: post step parallel.

Any suggestions? Example of my code:

post { 
  always { 
     script{ 
         cleanup(env1) 
         cleanup(env2) 
      }
   } 

 def cleanup(env) 
    withEnv(env) 
    { 
         sh "./cleanup.py" 
     } 
}  

Björn Pedersen

unread,
Jul 22, 2021, 9:53:36 AM7/22/21
to Jenkins Users
Take a look at the end of your stackoverflow link:
 You can use parallel inside a script block even in a post block.
Just  remember that inside a script block you need to use the scripted syntax, not  the descriptive syntax.
Reply all
Reply to author
Forward
0 new messages