-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
79 lines (69 loc) · 3.31 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
77
78
79
properties([
gitLabConnection('gitlab'),
[$class: 'ParametersDefinitionProperty',
parameterDefinitions: [
[$class: 'StringParameterDefinition', name: 'branch', defaultValue: 'master', description: 'the branch to build'],
[$class: 'StringParameterDefinition', name: 'apiUrl', defaultValue: 'https://api-qa.aspose.cloud', description: 'api url'],
[$class: 'BooleanParameterDefinition', name: 'debugMode', defaultValue: 'false', description: 'debug mode'],
[$class: 'BooleanParameterDefinition', name: 'ignoreCiSkip', defaultValue: false, description: 'ignore CI Skip'],
[$class: 'StringParameterDefinition', name: 'credentialsId', defaultValue: '6839cbe8-39fa-40c0-86ce-90706f0bae5d', description: 'credentials id'],
[$class: 'BooleanParameterDefinition', name: 'packageTesting', defaultValue: false, description: 'Testing package from repository without local sources. Used for prodhealthcheck'],
]
]
])
def runtests(dockerImageVersion)
{
def needToBuild = false
dir(dockerImageVersion){
try {
stage('checkout'){
checkout([$class: 'GitSCM', branches: [[name: params.branch]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "**"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-ruby.git']]])
sh 'git show -s HEAD > gitMessage'
def commitMessage = readFile('gitMessage').trim()
echo commitMessage
needToBuild = params.ignoreCiSkip || !commitMessage.contains('[ci skip]')
sh 'git clean -fdx'
if (needToBuild) {
withCredentials([usernamePassword(credentialsId: params.credentialsId, passwordVariable: 'ClientSecret', usernameVariable: 'ClientId')]) {
sh 'mkdir -p Settings'
sh 'echo "{\\"ClientId\\": \\"$ClientId\\",\\"ClientSecret\\": \\"$ClientSecret\\", \\"BaseUrl\\": \\"$apiUrl\\", \\"Debug\\" : $debugMode}" > Settings/servercreds.json'
}
}
}
if (needToBuild) {
docker.image('ruby:' + dockerImageVersion).inside('-u root'){
if (params.packageTesting) {
sh "mv GemfileTest Gemfile"
}
stage('build'){
sh "mkdir testReports"
sh "gem install bundler -v 2.0.2 && bundle install"
}
stage('tests'){
try{
sh 'rake test'
} finally{
junit 'testReports/report/*.xml'
}
}
stage('bdd-tests'){
}
stage('clean-compiled'){
sh "rm -rf %s"
}
}
}
} finally {
cleanWs()
}
}
}
node('words-linux') {
stage('newruby'){
try {
runtests("3.1")
} finally {
cleanWs()
}
}
}