jenkinsci / date-parameter-plugin

Date paramter plugin for jenkins
https://plugins.jenkins.io/date-parameter/
15 stars 20 forks source link

how can i use it in jenkinsfile ? #11

Closed beykery closed 2 years ago

beykery commented 3 years ago

how can i use date parameter in jenkinsfile just like booleanParam(......) in parameters section ?

LarrysGIT commented 2 years ago

Looking for the same. I figured out a workaround, it is a string after all.

def now = new Date()
def strNow = now.format("yyyy-MM-dd HH:mm:ss")
pipeline {
    agent any
    parameters {
        string(name: 'test', defaultValue: "$strNow", description: '')
    }
    stages {
        stage('stage1') {
            steps {
                script {
                    println "$test"
                }
            }
        }
    }
}
beykery commented 2 years ago

@LarrysGIT thx.

ionutale commented 2 years ago

arameters sec

so it does not have a named function?