如何访问标签中轴的值?

How to access value of an axis in a label?

...
        matrix {
            axes {
              axis {
                name 'FOO'
                values 'foo1' 'foo2'   // 
              }
...            stages {
                stage ('doIt') {
                    agent{
                      label '???'
                    }
                
...

我想构建一个 label 指令,它将接受 winmac,如果也找到了 FOO 的值之一。如何将轴的值与其他字符串组合起来形成有意义的标签?

您可以通过名称访问轴变量 - FOO。您唯一需要记住的是在双引号字符串中使用它,这样可以正确插入值。

pipeline {
    agent none
    stages {
        stage('Matrix example') {
            matrix {
                agent any
                axes {
                    axis {
                        name 'FOO'
                        values 'bar1', 'bar2', 'bar3'
                    }
                }
                stages {
                    stage('Test') {
                        agent {
                            label "${FOO}"
                        }
                        steps {
                            // ...
                        }
                    }
                }
            }
        }
    }
}