jenkinsci / jenkinsci/lockable-resources-plugin
[JENKINS-63708] Pipeline: Matrix and Lockable don't play well together
- Dominant language
- Java
- Stars
- 99
- Forks
- 205
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 8
Description
I have a declarative-pipeline and am using a matrix to perform system tests. One of the axis of the matrix is name=PLATFORM (values=Windows, Linux). I'd like to create a step with a lock on it based on the value of platform, hence, something like this:
matrix {
axes {
axis {
name = 'PLATFORM'
values = Windows', 'Linux'
}
}
options {
lock( label: "LOCK_${PLATFORM}", quantity: 1 )
}
stages {
...
// the above lock could also be applied to a stage within this stages block
}
}
If I read the documentation, I think this is supposed to work as the axis values are supposed to be able to be referenced from 'options' setup. However, when I run this, I get one of two errors:
- Referenced as "LOCK_${env.PLATFORM}" yields lock does not exist "LOCK_null"
- Referenced as "LOCK_${PLATFORM}" yields no such property "PLATFORM"
I have tried it at various levels - 1) as above, on the stages block, and 2) on a stage within the stages. They both fail in similar ways.
The intent here is that we would grab (or wait for) the LOCK_Windows or the LOCK_Linux as appropriate.
It seems like the axis value is not passed through to the options-block, or to the lock-command within the option.
---
Originally reported by jbennett20912, imported from: Pipeline: Matrix and Lockable don't play well together
Raw content of original issue
I have a declarative-pipeline and am using a matrix to perform system tests. One of the axis of the matrix is name=PLATFORM (values=Windows, Linux). I'd like to create a step with a lock on it based on the value of platform, hence, something like this:
matrix {
axes {
axis {
name = 'PLATFORM'
values = Windows', 'Linux'
}
}
options {
lock( label: "LOCK_${PLATFORM}", quantity: 1 )
}
stages {
...
// the above lock could also be applied to a stage within this stages block
}
}If I read the documentation, I think this is supposed to work as the axis values are supposed to be able to be referenced from 'options' setup. However, when I run this, I get one of two errors:
- Referenced as "LOCK_${env.PLATFORM}" yields lock does not exist "LOCK_null"
- Referenced as "LOCK_${PLATFORM}" yields no such property "PLATFORM"
I have tried it at various levels - 1) as above, on the stages block, and 2) on a stage within the stages. They both fail in similar ways.
The intent here is that we would grab (or wait for) the LOCK_Windows or the LOCK_Linux as appropriate.
It seems like the axis value is not passed through to the options-block, or to the lock-command within the option.
- environment:
Jenkins 2.249.1
Contributor guide
Assessment
This issue has not been assessed yet.