How to get build time stamp from Jenkins build variables?

前端 未结 10 1010
余生分开走
余生分开走 2020-12-24 11:25

How can I get build time stamp of the latest build from Jenkins? I want to insert this value in the Email subject in post build actions.

10条回答
  •  感动是毒
    2020-12-24 12:04

    One way this can be done is using shell script in global environment section, here, I am using UNIX timestamp but you can use any shell script syntax compatible time format:

    pipeline {
    
        agent any
    
        environment {
            def BUILDVERSION = sh(script: "echo `date +%s`", returnStdout: true).trim()
        }
    
        stages {
            stage("Awesome Stage") {
                steps {
                    echo "Current build version :: $BUILDVERSION"
                }
            }
        }
    }
    

提交回复
热议问题