forked from upyog/upyog-configs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
41 lines (37 loc) · 1.26 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
def app = "";
def commit_id="";
def module_name = "${env.JOB_NAME}".split("/")[-2];
def service_name = "${env.JOB_BASE_NAME}";
def path = "${module_name}/${service_name}"
def build_wkflo;
def ci_image = "egovio/ci:0.0.4"
def notifier = "";
try {
node("slave"){
checkout scm
sh "git rev-parse --short HEAD > .git/commit-id".trim()
commit_id = readFile('.git/commit-id')
def docker_file_exists = fileExists("${path}/Dockerfile")
code_builder = load("jenkins/code_builder.groovy")
notifier = load("jenkins/notifier.groovy")
currentBuild.displayName = "${BUILD_ID}-${commit_id}"
if (!docker_file_exists) {
code_builder.build(path, ci_image)
}
else {
archiver = load("jenkins/archiver.groovy")
image_builder = load("jenkins/image_builder.groovy")
code_builder.build(path, ci_image)
archiver.archiveArtifacts(["${path}/target/*.jar", "${path}/target/*.html"])
image_builder.build(module_name, service_name, commit_id)
image_builder.publish(service_name, commit_id)
image_builder.clean(service_name, commit_id)
}
}
} catch (e) {
node{
echo
notifier.notifyBuild("FAILED")
throw e
}
}