小编Ibt*_*sam的帖子

jenkins管道中的Active Choices反应参考参数

我在dsl作业中使用Active Choices反应参考参数插件,此处代码

 parameters {
                  activeChoiceParam('choice1') {
                      description('select your choice')
                      choiceType('RADIO')
                      groovyScript {
                          script("return['aaa','bbb']")
                          fallbackScript('return ["error"]')
                      }
                  }
                  activeChoiceReactiveParam('choice2') {
                      description('select your choice')
                      choiceType('RADIO')
                      groovyScript {
                          script("if(choice1.equals("aaa")){return ['a', 'b']} else {return ['aaaaaa','fffffff']}")
                          fallbackScript('return ["error"]')
                      }
                      referencedParameter('choice1')
                  }
Run Code Online (Sandbox Code Playgroud)

我现在想要的是如何在jenkinsFile中使用activeChoiceReactiveParam进行管道作业,这很好,我做到了:

properties(
    [
            [
                    $class              : 'ParametersDefinitionProperty',
                    parameterDefinitions: [
                            [
                                    $class     : 'ChoiceParameterDefinition',
                                    choices    : 'aaa\nbbb',
                                    description: 'select your choice : ',
                                    name       : 'choice1'
                            ]
Run Code Online (Sandbox Code Playgroud)

但是我怎么能添加choice2参数!

groovy jenkins jenkins-plugins jenkins-pipeline

7
推荐指数
4
解决办法
2万
查看次数

如何将作业放在jenkins的文件夹中?

我正在尝试使用jenkins DSL脚本将作业放入文件夹中现在,我创建一个listView并将我使用的代码放入作业中

listView('MyJobsList') {
  jobs {
     map.each{
       name((it.key).trim())
     }
  }
   columns{
        status()
        weather()
        name()
        lastSuccess()
        lastFailure()
        lastDuration()
        buildButton()
    }
}
Run Code Online (Sandbox Code Playgroud)

我想做同样的事情,但是这次我想把工作放在一个文件夹中!

groovy jenkins jenkins-job-dsl jenkins-pipeline

5
推荐指数
1
解决办法
5558
查看次数

jenkins pipline:如何从工作区获取文件列表?

在 jenkinsfile 中,我想获取工作区目录中的文件列表并将它们放入参数中。我试过:

stage('select'){
    def workspace = pwd()
    files = []
    new File  ("$workspace/buildFile").eachFile(FileType.FILES) { files << it.name }

    BuildFile = input( id: 'userInput', message: 'Sélectionner un backup', parameters: [ [$class: 'ChoiceParameterDefinition', choices: files , description: 'Properties', name: 'param'] ])   
}
Run Code Online (Sandbox Code Playgroud)

但我收到消息错误“java.io.FileNotFoundException:”

parameters groovy jenkins jenkins-pipeline

3
推荐指数
1
解决办法
6104
查看次数