-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
88 lines (69 loc) · 2.1 KB
/
build.gradle
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
plugins {
id 'base'
// id "org.ajoberstar.grgit" version "2.1.0"
}
description = 'Gradle Job Deployment Script'
version = '1.0'
ext {
jjName = 'qmic-JOB_PARAM_ASSEMBLER'
job_name='JOB_PARAM_ASSEMBLER'
jenkinsHome=System.getenv("JENKINS_HOME")//.replace('\\','/')
scriptletPath="$jenkinsHome/scriptler/scripts"
newScriptlets= []
if (new File("scriptler/scripts").exists()){
new File("scriptler/scripts").eachFile{newScriptlets.add(it.name)}
} //end if_exists
}
task copyConfig(type: Copy) {
from "jobs/$job_name/config.xml"
into "$jenkinsHome/jobs/$job_name/"
// rename { filename ->
// filename.replace 'xml', 'deploy'
// }
inputs.sourceFiles.stopExecutionIfEmpty()
}
task copyJobProperties(type: Copy) {
from "jobs/$job_name/buildProps"
into "$jenkinsHome/jobs/$job_name/buildProps"
}
task copyJobScripts(type: Copy) {
from "jobs/$job_name/buildScripts"
into "$jenkinsHome/jobs/$job_name/buildScripts"
}
task copyScriptlets(type: Copy) {
from "scriptler/scripts"
into "$jenkinsHome/scriptler/scripts"
}
task copyExternals(type: Copy) {
description "copies external scripts to Jenkins libs folder"
from "externalScripts"
into "$jenkinsHome/libs/externals"
}
task deploy(dependsOn: ['backup','copyConfig','copyJobProperties','copyJobScripts','copyScriptlets','copyExternals']){
doLast {
println "$job_name Successfully deployed"
}
}
task backup(type: Copy){
if (! new File("backup").exists()){
copy {from "$jenkinsHome/jobs/$job_name/config.xml"
into "backup/$job_name/"}
copy {from "$jenkinsHome/jobs/$job_name/buildScripts"
into "backup/$job_name/buildScripts"}
copy {from "$jenkinsHome/jobs/$job_name/buildProps"
into "backup/$job_name/buildProps"}
newScriptlets.each{
println "$jenkinsHome/scriptler/scripts/$it"
from "$jenkinsHome/scriptler/scripts/$it"
into "backup/scriptler/scripts"
}
}
}
//task cloneGitRepo{
//
//doLast {
//
// grgit.clone(dir: file("$jjName"), uri: "https://[email protected]/novartisnibr/${jjName}.git")
//
// }
// }