forked from rfrabasile/ff-api-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
89 lines (71 loc) · 3.55 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
import hudson.model.*
m1 = System.currentTimeMillis()
m2 = 0
durTime = 0
lock(resource: "${env.JOB_NAME}_${env.BRANCH_NAME}", inversePrecedence: false) {
node() {
deleteDir()
//################################
// STATIC VAR!!!
env.stepsMapNameJenkins = 'stepsMapNpm'
env.projectName = "NPMMOD"
// ###############################
try {
// System Env //
env.serviceName = "${env.JOB_NAME}".split('/')[1]
stage('Checkout') {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github_admin_ffoperationscol', name: 'origin', refspec: '+refs/heads/master:refs/remotes/origin/master', url: 'https://github.com/FLOWFACT/' + serviceName + '.git']]])
sh "mkdir pipeline"
dir('pipeline') {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github_admin_ffoperations', name: 'origin', refspec: '+refs/heads/master:refs/remotes/origin/master', url: 'https://github.com/FLOWFACTCorp/jenkins-pipeline-steps.git']]])
}
sh "mkdir tests"
dir('tests') {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github_admin_ffoperations', name: 'origin', refspec: '+refs/heads/master:refs/remotes/origin/master', url: 'https://github.com/FLOWFACTCorp/jenkins-test-automation.git']]])
}
}
func = load('pipeline/functions/func.groovy');
def vars = load('pipeline/functions/loadVarsLibs.groovy');
vars.loadVars()
// Pipeline Steps - while
count = 1
int stepsCount = stepsCount.toInteger()
while (count <= stepsCount) {
try {
name = "${count}_name"
env.step_name = mapping[name]
echo "step_name: "+step_name
stage("${step_name}") {
def steps = load('pipeline/functions/steps.groovy');
steps.stepToLoad(count)
}
count++;
}
catch (err) {
println err
throw err
}
}
m2 = System.currentTimeMillis()
durTime = func.durationTime(m1, m2)
mapping = readProperties file: pwd() + '/pipeline/'+productName+'/'+stepsMapName+'.properties'
step_job = mapping['end_ok_job']
sload = "pipeline/"+productName+"/${step_job}.groovy"
def end = load(sload);
end.endPositive()
currentBuild.result = 'SUCCESS'
} catch (err) {
func = load('pipeline/functions/func.groovy');
def vars = load('pipeline/functions/loadVarsLibs.groovy');
vars.loadVars()
mapping = readProperties file: pwd() + '/pipeline/'+productName+'/'+stepsMapName+'.properties'
step_job = mapping['end_err_job']
sload = "pipeline/"+productName+"/${step_job}.groovy"
def end = load(sload);
end.endNegative()
currentBuild.result = 'FAILED'
println err
throw err
}
}
}