-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.github
75 lines (70 loc) · 1.84 KB
/
Jenkinsfile.github
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
githubOwner = 'AccelByte'
githubRepo = 'accelbyte-api-proto'
githubSsh = 'accelbyte-sdk-sdkbuild-ssh'
githubUrl = "git@github.com:${githubOwner}/${githubRepo}.git"
pipeline {
agent {
label "justice-codegen-sdk"
}
stages {
stage('Prepare') {
steps {
script {
currentBuild.displayName = "#${env.BUILD_NUMBER}"
gitHost = sh(script: "echo '${githubUrl}' | grep -oP '(?<=@).+(?=:)'", returnStdout: true).trim()
sh "grep -q ${gitHost} ~/.ssh/known_hosts || ssh-keyscan ${gitHost} | tee -a ~/.ssh/known_hosts"
}
}
}
stage('Push') {
when {
expression {
return params.ACTION == 'PUSH'
}
}
steps {
script {
sh "git checkout master"
sshagent(credentials: [githubSsh])
{
sh "git push ${githubUrl} HEAD:main"
}
}
}
}
stage('Release') {
when {
expression {
return params.ACTION == 'PUSH+RELEASE'
}
}
steps {
script {
sh "git checkout ${params.RELEASE_BRANCH}"
sshagent(credentials: [githubSsh])
{
if (params.RELEASE_BRANCH == "master") {
sh "git push ${githubUrl} HEAD:main"
}
else {
sh "git push ${githubUrl} HEAD:${params.RELEASE_BRANCH}"
}
sh "git push ${githubUrl} ${params.RELEASE_TAG}"
}
}
}
}
}
post {
failure {
script {
message = """
:no_entry: <${env.BUILD_URL}|${env.JOB_NAME}-${env.BUILD_NUMBER}> *failed*
|*Action*
|${params.ACTION}
|""".stripMargin()
slackSend(channel: "#activity-extend-engineering", color: '#FF0000', message: message)
}
}
}
}