-
Notifications
You must be signed in to change notification settings - Fork 0
/
new.Jenkinsfile
88 lines (76 loc) · 2.67 KB
/
new.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
pipeline {
agent {
label 'caila-dev-cloud-agent'
}
parameters {
string(name: 'RELEASE_BRANCH', defaultValue: 'release', description: 'Ветка на основе которой выпускаем версию')
string(name: 'NEW_VERSION', defaultValue: '1.0.0', description: 'Новая версия из 3х цифр')
}
environment {
RELEASE_DEPLOY_PROFILE = 'nexus-open-release'
GITLAB_REPO = '[email protected]:ml-platform-pub/mlp-java-sdk.git'
GITHUB_REPO = '[email protected]:just-ai/mlp-java-sdk.git'
}
stages {
stage('Checkout') {
steps {
git branch: "${params.RELEASE_BRANCH}", url: env.GITLAB_REPO, credentialsId: 'bitbucket_key'
}
}
stage('Set Version') {
steps {
withMaven(maven: 'Maven 3.5', jdk: '11') {
sh "mvn versions:set -DnewVersion=${params.NEW_VERSION} -DgenerateBackupPoms=false"
}
}
}
stage('Deploy') {
steps {
withMaven(maven: 'Maven 3.5', jdk: '11') {
sh "mvn clean deploy -P ${env.RELEASE_DEPLOY_PROFILE}"
}
}
}
stage('Update Version Info') {
steps {
script {
def versionInfo = readJSON file: 'last-released-version.json'
versionInfo.currentVersion = params.NEW_VERSION
versionInfo.versions.add(0, params.NEW_VERSION)
writeJSON file: 'last-released-version.json', json: versionInfo, pretty: 4
}
}
}
stage('Revert to Snapshot Version') {
steps {
withMaven(maven: 'Maven 3.5', jdk: '11') {
sh "mvn versions:set -DnewVersion=dev-SNAPSHOT -DgenerateBackupPoms=false"
}
}
}
stage('Commit and Tag') {
steps {
sh """
git add last-released-version.json
git commit -m "update release version to ${params.NEW_VERSION}"
git tag release-${params.NEW_VERSION}
"""
}
}
stage('Push Changes') {
steps {
sh """
git push ${env.GITLAB_REPO} ${params.RELEASE_BRANCH}
git push ${env.GITLAB_REPO} --tags
git push ${env.GITHUB_REPO} ${params.RELEASE_BRANCH}
git push ${env.GITHUB_REPO} --tags
"""
}
}
}
post {
always {
cleanWs()
}
}
}