-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.nightly
114 lines (107 loc) · 4.22 KB
/
Jenkinsfile.nightly
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
library(
identifier: 'jenkins-shared-library@master',
retriever: modernSCM(
[
$class: 'GitSCMSource',
remote: 'https://github.com/dhanarab/jenkins-pipeline-library.git'
]
)
)
bitbucketCredentialsHttps = "bitbucket-build-extend-https"
bitbucketCredentialsSsh = "bitbucket-build-extend-ssh"
bitbucketCommitHref = null
jobChannel = env.SLACK_CHANNEL_ACTIVITY_EXTEND_CODEGEN_MODULAR_SDK ? env.SLACK_CHANNEL_ACTIVITY_EXTEND_CODEGEN_MODULAR_SDK : "#activity-justice-codegen-modular-sdk"
pipeline {
agent {
label "extend-builder-batch"
}
stages {
stage('Prepare') {
steps {
script {
gitRepositoryName = git.getRepositoryName()
gitCommitHash = git.getCommitHash()
bitbucketCommitHref = "https://api.bitbucket.org/2.0/repositories/accelbyte/${gitRepositoryName}/commit/${gitCommitHash}"
bitbucket.setBuildStatus(bitbucketCredentialsHttps, bitbucketCommitHref, "INPROGRESS", env.JOB_NAME.take(30), "${env.JOB_NAME}-${env.BUILD_NUMBER}", "Jenkins", "${env.BUILD_URL}console")
}
}
}
stage('Test') {
parallel {
stage('CLI Tests') {
steps {
sshagent(credentials: [bitbucketCredentialsSsh]) {
sh "rm -rf .justice-codegen-sdk-mock-server"
sh "git clone --depth 1 [email protected]:accelbyte/justice-codegen-sdk-mock-server .justice-codegen-sdk-mock-server"
}
sh "make test_cli SDK_MOCK_SERVER_PATH=.justice-codegen-sdk-mock-server"
}
post {
always {
script {
archiveArtifacts artifacts: 'samples/cli/tests/*.tap'
step([$class: "TapPublisher", testResults: "samples/cli/tests/*.tap"])
}
}
}
}
stage('Integration Tests') {
options {
lock("justice-demo-serversdktest")
}
environment {
DEFAULT_IFACE = sh(script: 'ip route get 1.1.1.1 | awk \'NR==2 {print $1}\' RS=dev', returnStdout: true)
}
steps {
sh 'sudo tc qdisc add dev $DEFAULT_IFACE root netem delay 100ms' // Delay sending packets due to database eventual consistency
withCredentials([
file(credentialsId: 'justice-codegen-sdk-integration-test-env', variable: 'ENV_FILE_PATH'),
]) {
sh 'make test_integration ENV_FILE_PATH=$ENV_FILE_PATH'
}
}
post {
always {
script {
sh 'sudo tc qdisc del dev $DEFAULT_IFACE root netem delay 100ms'
sh 'rm -f tests/integration/.env'
archiveArtifacts artifacts: 'test_integration.tap'
step([$class: "TapPublisher", testResults: "test_integration.tap"])
}
}
}
}
}
}
}
post {
success {
script {
bitbucket.setBuildStatus(bitbucketCredentialsHttps, bitbucketCommitHref, "SUCCESSFUL", env.JOB_NAME.take(30), "${env.JOB_NAME}-${env.BUILD_NUMBER}", "Jenkins", "${env.BUILD_URL}console")
//gitRepositoryName = git.getRepositoryName()
//gitBranchName = sh(script: "echo ${env.GIT_BRANCH} | grep -oP '(?<=origin/).+'", returnStdout: true).trim()
//gitCommitHashShort = git.getCommitHashShort()
//gitCommitMessage = git.getCommitMessage()
//
//message = """
// :white_check_mark: <${env.BUILD_URL}|${env.JOB_NAME}-${env.BUILD_NUMBER}> *updated*
//
// |*${gitRepositoryName}:*
// |`${gitBranchName}` `${gitCommitHashShort}`
// |${gitCommitMessage}
//
// |""".stripMargin()
//slackSend(channel: jobChannel, color: '#36B37E', message: message)
}
}
failure {
script {
bitbucket.setBuildStatus(bitbucketCredentialsHttps, bitbucketCommitHref, "FAILED", env.JOB_NAME.take(30), "${env.JOB_NAME}-${env.BUILD_NUMBER}", "Jenkins", "${env.BUILD_URL}console")
message = """
:no_entry: <${env.BUILD_URL}|${env.JOB_NAME}-${env.BUILD_NUMBER}> *failed*
|""".stripMargin()
slackSend(channel: jobChannel, color: '#FF0000', message: message)
}
}
}
}