-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
110 lines (87 loc) · 2.87 KB
/
build.gradle
File metadata and controls
110 lines (87 loc) · 2.87 KB
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
99
100
101
102
103
104
105
106
107
108
defaultTasks 'buildImages'
//to print commandline for easy debuging
allprojects {
tasks.withType(Exec) {
doFirst {
String cmdPrint = commandLine
println 'Command to run:' + cmdPrint.replace(',','')
}
}
}
task createBuildDir(){
buildDir.mkdirs()
}
task buildImages(dependsOn: ['buildJenkins','buildSonar']){
}
task buildJenkins(type: Exec) {
workingDir 'dockerFiles/jenkins/'
commandLine 'docker', 'build', '-t', 'easybuilder_jenkins:0.1', '.'
}
task buildSonar(type: Exec) {
workingDir 'dockerFiles/sonar/'
commandLine 'docker', 'build', '-t', 'easybuilder_sonar:0.1', '.'
}
/*
task runImages(type: Exec) {
commandLine 'sh', 'scripts/start_images.sh'
}
*/
task runImages(dependsOn: ['runSonar','runJenkins']) {
}
task runSonar(type: Exec,dependsOn: ['buildSonar','createBuildDir'],) {
commandLine 'docker', 'run', '-p', '19000:9000', '-p', '15432:5432', '--name', 'sonar01', '-t', 'easybuilder_sonar:0.1'
}
task runJenkins(type: Exec,dependsOn: ['buildJenkins','createBuildDir']) {
//commandLine 'docker', 'run', '-p', '18080:8080', '--name', 'jenkins09', '-v' , "${buildDir}/jenkins_home:/var/lib/jenkins" ,'-t', 'easybuilder_jenkins:0.1'
commandLine 'docker', 'run', '-p', '18080:8080', '--name', 'jenkins01', '-v' , "${buildDir}/jenkins_home:/jenkins" ,'-t', 'easybuilder_jenkins:0.1'
}
task stopRemoveImages(dependsOn: ['removeSonar','removeJenkins']) {
}
task stopSonar(type: Exec) {
commandLine 'docker', 'stop', 'sonar01'
}
task removeSonar(type: Exec,dependsOn: 'stopSonar') {
commandLine 'docker', 'rm', 'sonar01'
}
task stopJenkins(type: Exec) {
commandLine 'docker', 'stop', 'jenkins01'
}
task removeJenkins(type: Exec,dependsOn: 'stopJenkins') {
commandLine 'docker', 'rm', 'jenkins01'
}
task checkInternet() {
doLast {
if (checkInternetConnection()) {
System.out.println("true");
} else {
System.out.println("false");
//throw new GradleException('no internet connection might be proxy settings')
}
if (checkInternetConnectionProxy()) {
System.out.println("true proxy");
} else {
System.out.println("false proxy");
throw new GradleException('proxy no internet connection might be proxy settings')
}
}
}
def checkInternetConnection() {
int timeout = 1500;
try {
return InetAddress.getByName("www.nl.cx").isReachable(timeout)
} catch (Exception e) {
System.out.println("Unknown Host: " + e);
}
return false;
}
def checkInternetConnectionProxy() {
int timeout = 1500;
try {
System.setProperty("https.proxyHost", "10.12.9.101");
System.setProperty("https.proxyPort", "8080");
return InetAddress.getByName("www.nl.cx").isReachable(timeout)
} catch (Exception e) {
System.out.println("Unknown Host: " + e);
}
return false;
}