Jenkins 日期参数插件 - 如何在声明式管道中使用它

标签 jenkins jenkins-plugins jenkins-pipeline

在声明性管道中使用日期参数插件的语法是什么。

到目前为止,我已经尝试过这个:

pipeline {
agent {
    node {
        label 'grange-jenkins-slave'
    }
}

options { disableConcurrentBuilds() }

parameters {
    date(name: 'EffectiveDate',
            dateFormat: 'MMddyyy',
            defaultValue: 'LocalDate.now();',
            description: 'Effective Date',
            trim: true)
    file(name:'algo.xlsx', description:'Your algorithm file')
    choice(name: 'currency',
            choices: ['USD'],
            description: 'Select a currency')

}
stages {
    stage('genRates') {
        steps {
            script {
                echo "test"
            }
        }
    }
}

}

我得到的错误是 WorkflowScript: 11: Invalid parameter type "date". Valid parameter types: [booleanParam, choice, credentials, file, text, password, run, string] @ line 11, column 3.

最佳答案

您可以定义参数 as class DateParameterDefinition .

例子:

properties([parameters([
  string(name: 'somestring', defaultValue: 'somevalue'),
  [$class: 'DateParameterDefinition',
   name: 'somedate',
   dateFormat: 'yyyyMMdd',
   defaultValue: 'LocalDate.now()']
])])

pipeline {
...
}

关于Jenkins 日期参数插件 - 如何在声明式管道中使用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53712774/

相关文章:

jenkins - 是否有 Jenkins 插件允许您手动操作构建队列

git - Jenkins 管道环境变量

jenkins - 如何在 Jenkins 声明性管道脚本 block 内循环分配 env

git 存储库在从 linux 中的 jenkins 连接时出现 403 错误

jenkins - 如何在另一个jenkins管道B中调用jenkins管道A

jenkins - 如何删除 Jenkins 中的 View 并自动删除其作业?

jenkins - 如何向 Jenkins 添加条件参数

git - Jenkins的Gradle发布插件未推送发布版本

continuous-integration - 阻塞 jenkins 任务直到所有下游任务完成?

Jenkins ArtifactDeployer 插件 - 如何将本地目录指定为远程目录