Add bat variant of git commands

This commit is contained in:
Dan Hawkins 2018-12-03 08:48:11 +00:00
commit 66082496ba

View file

@ -10,42 +10,35 @@ def getGitRevision(String gitrootpath, int basebuildnumber) {
def String remoteinfo
def String remoteurl
dir( gitrootpath) {
def int changecount
def int changecount = 0
if (isUnix()) {
changecount = sh(returnStdout: true, script: "git rev-list HEAD --count").trim().toInteger()
}
else {
def stdout = bat(returnStdout:true , script: "git rev-list HEAD --count").trim()
changecount = stdout.readLines()[1] as int
}
changecount = bat(returnStdout: true, script: "@git rev-list HEAD --count").trim().toInteger()
}
echo "Change count: ${changecount}"
adjustedchangecount = (changecount + basebuildnumber) % (maxversionnumber() + 1)
echo "Adjusted change count: ${adjustedchangecount}"
if (isUnix()) {
gitrevision = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
}
else {
def stdout = bat(returnStdout:true , script: "git rev-parse HEAD").trim()
gitrevision = stdout.readLines()[1]
gitrevision = bat(returnStdout: true, script: "@git rev-parse HEAD").trim()
}
echo "Revision: ${gitrevision}"
if (isUnix()) {
remoteinfo = sh(returnStdout: true, script: "git remote show origin").trim()
}
else {
def stdout = bat(returnStdout:true , script: "git remote show origin").trim()
remoteinfo = stdout.readLines()[1..-1]
remoteinfo = bat(returnStdout: true, script: "@git remote show origin").trim()
}
echo "Remote info: ${remoteinfo}"
if (isUnix()) {
remoteurl = sh(returnStdout: true, script: "git config --get remote.origin.url").trim()
}
else {
def stdout = bat(returnStdout:true , script: "git config --get remote.origin.url").trim()
remoteurl = stdout.readLines()[1]
remoteurl = bat(returnStdout: true, script: "@git config --get remote.origin.url").trim()
}
echo "Remote URL: ${remoteurl}"
}