-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile
98 lines (87 loc) · 4.69 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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: '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 needToBuild = false
def packageTesting = false
def runtests(dockerImageVersion)
{
dir(dockerImageVersion){
try {
stage('checkout'){
checkout([$class: 'GitSCM', branches: [[name: params.branch]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-node.git']]])
sh 'git show -s HEAD > gitMessage'
def commitMessage = readFile('gitMessage').trim()
echo commitMessage
needToBuild = params.ignoreCiSkip || !commitMessage.contains('[ci skip]')
packageTesting = params.packageTesting
sh 'git clean -fdx'
def apiUrl = params.apiUrl
if (needToBuild) {
withCredentials([usernamePassword(credentialsId: params.credentialsId, passwordVariable: 'ClientSecret', usernameVariable: 'ClientId')]) {
sh 'echo "{\\"ClientId\\": \\"$ClientId\\",\\"ClientSecret\\": \\"$ClientSecret\\", \\"BaseUrl\\":\\"$apiUrl\\"}" > testConfig.json'
}
}
}
if (needToBuild) {
docker.image('node:' + dockerImageVersion).inside{
if (packageTesting) {
stage('remove sources and redefine referencies'){
sh "npm uninstall asposewordscloud"
sh "sed -i 's/asposewordscloud/asposewordscloudtest/g' package.json"
sh "rm -rf src"
sh "find test -type f -name \"*.ts\" -exec sed -i 's+\".*/src/.*\"+\"asposewordscloud\"+g' {} +"
sh "find bdd -type f -name \"*.ts\" -exec sed -i 's+\".*/src/.*\"+\"asposewordscloud\"+g' {} +"
sh "npm install asposewordscloud"
}
}
stage('build'){
withEnv([
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
'npm_config_cache=npm-cache',
/* set home to our current directory because other bower
* nonsense breaks with HOME=/, e.g.:
* EACCES: permission denied, mkdir '/.config'
*/
'HOME=.',
]) {
sh "npm install"
sh "npm run tsc"
if (params.branch == 'refs/heads/master'){
sh "npm run lint"
}
}
}
stage('tests'){
try {
sh "npm run test-jenkins"
} finally {
junit 'reports/**.xml'
}
}
stage('bdd-tests'){
try {
sh "npm run cucumber"
} finally {
cucumber 'reports/**.json'
}
}
}
}
} finally {
deleteDir()
sh 'docker system prune -f'
}
}
}
node('words-linux') {
runtests("latest")
}