-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkinsfile
60 lines (58 loc) · 2.46 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 any
stages {
stage ("checkoutManual") {
steps {
deleteDir()
script {
try{
sh "echo existing"
checkout([$class: 'GitSCM', branches: [[name: "*/release/${env.release_version}"]], extensions: [[$class: 'CleanBeforeCheckout', deleteUntrackedNestedRepositories: true]],
userRemoteConfigs: [[credentialsId: '050dc3e8-6fb1-4cbd-815b-e920b7d8d46c', url: 'git@gitlab:root/cowsay.git']]])
}
catch (exc) {
checkout([$class: 'GitSCM', branches: [[name: "*/master"]], extensions: [[$class: 'CleanBeforeCheckout', deleteUntrackedNestedRepositories: true]],
userRemoteConfigs: [[credentialsId: '050dc3e8-6fb1-4cbd-815b-e920b7d8d46c', url: 'git@gitlab:root/cowsay.git']]])
sh "echo new"
sh """
git checkout -b release/${env.release_version}
echo ${env.release_version}.0,'NOT FOR RELEASE' > v.txt
git add .
git commit -m "initial comit of new release branch"
git push --set-upstream origin release/${env.release_version}
"""
}
}
}
}
stage ("Build") {
steps {
sh "./init-cowsay.sh ${env.release_version}"
}
}
stage ("Test") {
steps {
sh "sleep 5"
sh "curl cow:4001"
}
}
stage ("Release")
{
when {
branch '*/release/*'
}
steps{
sh """
echo ${env.release_version}.\$(git rev-list origin/release/${env.release_version} --count),'RELEASED' > v.txt
git add .
git commit -m "New Release"
git push origin HEAD:release/${env.release_version}
"""
sh "./docker-image-build.sh ${env.release_version}"
sh "./init.sh ${env.release_version}"
sh "git clean -n -d"
sh "git clean --force -n -d"
}
}
}
}