-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
76 lines (66 loc) · 2.45 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def gitBranch = "latest"
def gitURL = "git@github.com:Memphisdev/memphis-docker.git"
def repoUrlPrefix = "memphisos"
import hudson.model.*
import groovy.transform.Field
node ("memphis-jenkins-big-fleet,") {
git credentialsId: 'main-github', url: gitURL, branch: gitBranch
try{
stage('Login to Docker Hub') {
withCredentials([usernamePassword(credentialsId: 'docker-hub', usernameVariable: 'DOCKER_HUB_CREDS_USR', passwordVariable: 'DOCKER_HUB_CREDS_PSW')]) {
sh 'docker login -u $DOCKER_HUB_CREDS_USR -p $DOCKER_HUB_CREDS_PSW'
}
}
stage('Import version number from broker'){
dir('memphis-broker'){
git credentialsId: 'main-github', url: 'git@github.com:memphisdev/memphis-broker.git', branch: gitBranch
}
sh """
cat memphis-broker/version.conf | cut -d "-" -f1 > version.conf
rm -rf memphis-broker
"""
}
stage('Checkout to version branch'){
withCredentials([sshUserPrivateKey(keyFileVariable:'check',credentialsId: 'main-github')]) {
sh "git reset --hard origin/latest" //change to latest
sh"""
GIT_SSH_COMMAND='ssh -i $check' git checkout -b v\$(cat version.conf)
GIT_SSH_COMMAND='ssh -i $check' git push --set-upstream origin v\$(cat version.conf)
"""
}
}
stage('Create new release') {
sh 'sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo -y'
sh 'sudo dnf install gh -y'
sh 'sudo dnf install jq -y'
withCredentials([string(credentialsId: 'gh_token', variable: 'GH_TOKEN')]) {
sh(script:"""gh release create v\$(cat version.conf) --generate-notes --target latest""", returnStdout: true)
}
}
stage('Merge to gh-pages'){
}
notifySuccessful()
}
catch (e) {
currentBuild.result = "FAILED"
cleanWs()
notifyFailed()
throw e
}
}
def notifySuccessful() {
emailext (
subject: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':
Check console output and connection attributes at ${env.BUILD_URL}""",
recipientProviders: [requestor()]
)
}
def notifyFailed() {
emailext (
subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':
Check console output at ${env.BUILD_URL}""",
recipientProviders: [requestor()]
)
}