@@ -23,8 +23,9 @@ def build(*args):
23
23
#return subprocess.check_output(['mvn'] + list(args),shell=True)
24
24
25
25
#https://coderwall.com/p/tjc9oa/for-those-who-build-multiple-maven-projects-at-once
26
- def mvnbuild (dir ):
27
- os .chdir (dir )
26
+ def mvnbuild (cdir ):
27
+ cwd = os .getcwd ()
28
+ os .chdir (cdir )
28
29
process = subprocess .Popen (
29
30
#"mvn clean install -DskipTests=true"
30
31
"mvn clean install" ,
@@ -34,6 +35,7 @@ def mvnbuild(dir):
34
35
#log(out, dir)
35
36
#print(out)
36
37
errcode = process .returncode
38
+ os .chdir (cwd )
37
39
return (out , err , errcode )
38
40
39
41
@@ -44,26 +46,26 @@ def mvnbuild(dir):
44
46
print (" Plese provide proper arguments in the form python BuildProjects <FOLDE PATH where projects are cloned <MAVEN command to run>" )
45
47
46
48
47
- projectstobuild = os .listdir (clonedprojectfolder )
49
+ projectstobuild = [ i for i in os .listdir (clonedprojectfolder ) if ( os . path . isdir ( os . path . join ( clonedprojectfolder + i )))]
48
50
logfile = open ('Build_log_' + str (datetime .datetime .now ()),'a' )
49
51
50
52
print ("Processing projects in folder ::" + clonedprojectfolder )
51
53
projcount = len (projectstobuild )
52
54
failedprojcount = 0
53
55
processedprojcount = 0
54
- # print("Total projects to build "+ str(projcount))
56
+ print ("Total projects to build " + str (projcount ))
55
57
#logfile.write("Total projects to build "+ str(projcount)+"\n")
56
58
57
59
58
- for dir in projectstobuild :
59
- path = dir
60
+ for p in projectstobuild :
61
+ path = p
60
62
fullpath = os .path .join (clonedprojectfolder + path )
61
63
#print(fullpath)
62
64
if (os .path .isdir (fullpath )):
63
65
currfilelog = open ('path.log' ,'a' )
64
66
try :
65
67
#https://stackoverflow.com/questions/21377520/do-a-maven-build-in-a-python-script
66
- if (not (dir .startswith ('.' ))):
68
+ if (not (p .startswith ('.' ))):
67
69
print ("Procesiing " + path )
68
70
opofbuild = mvnbuild (fullpath )
69
71
if ("BUILD SUCCESS" in opofbuild [0 ]):
@@ -72,6 +74,7 @@ def mvnbuild(dir):
72
74
else :
73
75
print ("Build failed for project " + path + "\n " )
74
76
logfile .write ("Build failed for project " + path + "\n " )
77
+ #logfile..write(op)
75
78
'''
76
79
with changeDir(fullpath):
77
80
# ****** NOTE ******: using shell=True is strongly discouraged since it possesses security risks
0 commit comments