Issue
Question: I need to set 2 hrs time for Node Allocation, Once Node is allocated within time limit, Build should continue, If node is not allocated within time frame, Build should Aboarted.
I tried with timeout function, But in these, If node is allocated, once the time limit is reached then build is aborted in mid of exection.
startTime = System.currentTimeMillis()
timeout(time:2, unit: 'HOURS'){
node('Slave_Node') {
// Will run on the slave
}
}
In console it will print during waiting like, "Waiting for next available executor on 'Slave_Node'"
Once the node is allocated, "Running on Slave_Node"
Can suggest Implementation plz. Thanks :)
Solution
Use this instead:
startTime = System.currentTimeMillis()
timeout(activity: true, time: 2, unit: 'HOURS') {
node('Slave_Node') {
// Will run on the slave
}
}
The activity: true
will timeout after no activity in logs for the defined block instead of absolute duration.
Answered By - hdhruna
Answer Checked By - Clifford M. (JavaFixing Volunteer)