Closed dcoraboeuf closed 5 years ago
In a declarative pipeline, when using:
stage("x") {
agent { }
}
the time to create the agent if not available is taken into account when measuring the timing of the x
stage:
It's a same issue with a scripted pipeline written this way:
stage("x") {
node {
}
}
When inverting the syntax:
node {
stage("x") {}
}
then the computation is OK:
So it means that have to take into account the cases of:
i) declarative pipeline ii) node creation inside a declarative stage
The case iii) node creation outside of a stage is already correct.
Proposal: when computing the execution time of a stage, we go up the step tree until we find the stage step itself. We take its execution time s
.
On the way up the tree, we collect each "Allocate node" step execution time into the n
time.
The computed stage execution time will be x = s - t
.
This will solve cases i) and ii) (and also work for iii) where t = 0
)
"Allocate Node: Start" (n
) and "Allocate Node: Body: Start" (b
) have to be taken into account.
If no such step is seen before we get to the stage, t = s
.
If not, t = sum(b)
where b
is the list of "Node: Body: Start" steps.
Fixed in 3.4
The current way to get the execution time for a stage if to get the total timing of the stage ; this includes queuing time and node preparation time.
We want the time to be only about the execution of the stage.