// vars/gatherInfo.groovy def call(String branchOverride = null) { def duration = currentBuild.durationString.replace(' and counting', '') def commitMsg = sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim() def author = sh(returnStdout: true, script: 'git log -1 --pretty=%an').trim() def commitTime = sh(returnStdout: true, script: 'git log -1 --pretty=%ci').trim() def causes = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause') def builder = causes.isEmpty() ? 'auto' : causes[0].userId def branch = branchOverride ?: env.GIT_BRANCH ?: env.BRANCH_NAME ?: 'unknown' def buildUrl = env.BUILD_URL.replace('http://68.79.46.88:8080', 'https://jenkins.adwebcloud.com') return [ duration : duration, commitMsg: commitMsg, author : author, commitTime: commitTime, branch : branch, buildUrl : buildUrl, builder : builder ] }