This repository was archived by the owner on Feb 16, 2023. It is now read-only.
forked from logzio/logzio-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
60 lines (56 loc) · 1.69 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
pipeline {
agent {
label "jenkins-jx-base"
}
environment {
ORG = 'arturo-ai'
APP_NAME = 'logzio-k8s'
}
stages {
stage('Build and publish PR') {
when {
branch 'PR-*'
}
steps {
container('jx-base') {
script {
sh "jx step git credentials"
sh "git config credential.helper store"
next_version = sh(script: 'jx-release-version', returnStdout: true)
sh "docker build --no-cache -t $DOCKER_REGISTRY/$ORG/$APP_NAME:$next_version-$BRANCH_NAME-$BUILD_NUMBER ."
sh "docker push $DOCKER_REGISTRY/$ORG/$APP_NAME:$next_version-$BRANCH_NAME-$BUILD_NUMBER"
}
}
}
}
stage('Build and publish "master"') {
when {
branch 'master'
}
steps {
container('jx-base') {
sh '''
jx step git credentials
# ensure we're not on a detached head
git checkout master
# until we switch to the new kubernetes / jenkins credential implementation use git credentials store
git config credential.helper store
export VERSION="$(jx-release-version)"
echo "Releasing version to ${VERSION}"
docker build --no-cache -t $DOCKER_REGISTRY/$ORG/$APP_NAME:${VERSION} .
docker push $DOCKER_REGISTRY/$ORG/$APP_NAME:${VERSION}
docker tag $DOCKER_REGISTRY/$ORG/$APP_NAME:${VERSION} $DOCKER_REGISTRY/$ORG/$APP_NAME:latest
docker push $DOCKER_REGISTRY/$ORG/$APP_NAME
git tag -fa v${VERSION} -m "Release version ${VERSION}"
git push origin v${VERSION}
'''
}
}
}
}
post {
always {
cleanWs()
}
}
}