I have a following method to give available drive for windows in Shared library getAvailableDrive.groovy
#!groovy
def call(){
def drivesInfo=bat(script: '@echo off && fsutil fsinfo drives', returnStdout: true).trim()
usedDrives=drivesInfo.substring(8).tokenize(" ")
def drivesList=[]
for(alpha = 'A'; alpha <= 'Z'; ++alpha){
drivesList.add("${alpha}:\\")
}
usedDrives.each{
if(drivesList.contains("${it}"))
drivesList.remove("${it}")
}
if(0==usedDrives.size())
throw new Exception("No unused Drive/s Found!")
return drivesList[0].take(2)
}
We have single windows node with executers 10, When multiple pipelines run at a same time, sometimes getAvailableDrive() gives same value to different pipeline. I wanted pipelines to use getAvailableDrive() in sequence. Any input on resolving this issue would be very useful