added commit hash to docker image tag and trigger deployment job

This commit is contained in:
Sebastian Sdorra
2018-09-24 17:13:47 +02:00
parent fd6181e957
commit 9e69603de1

16
Jenkinsfile vendored
View File

@@ -45,14 +45,24 @@ node('docker') {
}
}
def commitHash = getCommitHash()
def dockerImageTag = "2.0.0-dev-${commitHash.substring(0,7)}-${BUILD_NUMBER}"
stage('Docker') {
// TODO only on mainBranch
def image = docker.build('cloudogu/scm-manager')
docker.withRegistry('', 'hub.docker.com-cesmarvin') {
image.push("2.0.0-dev-b${BUILD_NUMBER}")
image.push(dockerImageTag)
image.push('latest')
}
}
stage('Deployment') {
build job: 'scm-manager/next-scm.cloudogu.com', propagate: false, wait: false, parameters: [
string(name: 'changeset', value: commitHash),
string(name: 'imageTag', value: dockerImageTag)
]
}
}
// Archive Unit and integration test results, if any
@@ -123,6 +133,10 @@ String getCommitAuthorComplete() {
new Sh(this).returnStdOut 'hg log --branch . --limit 1 --template "{author}"'
}
String getCommitHash() {
new Sh(this).returnStdOut 'hg log --branch . --limit 1 --template "{node}"'
}
String getCommitAuthorEmail() {
def matcher = getCommitAuthorComplete() =~ "<(.*?)>"
matcher ? matcher[0][1] : ""