
在 Jenkins 中,我想根據屬性資料夾中設定的參數值在參數部分設定一個欄位。
每次我嘗試在階段部分之外使用 withFolderProperties 時,都會出現錯誤。所以我問下一個問題...
我可以用它來滿足我的需要嗎?
這是我的程式碼:
pipeline {
agent {
label "xxx.yyy"
}
parameters {
/* it doen't work*/
withFolderProperties{
choice(name: 'Projet', choices: [${cicdListeProjets}], description: 'Projet concerne')
}
}
tools {
jdk 'openjdk-8'
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
disableConcurrentBuilds()
}
stages {
stage('Checkout') {
steps {
checkout(...)
}
}
stage('Build') {
steps {
sh """
echo "$Projet"
"""
}
}
}
}
謝謝
答案1
根據文件,withFolderProperties
是一個管道步驟。腳步必須放入steps
聲明式管道的一部分。