@@ -31,7 +31,7 @@ def cloneCD(request):
3131 project = CDModels .Project .objects .get (name = request .GET ["project_name" ])
3232 c = Client (scm , ip , port , project .sshKey .key )
3333 res = c .Clone (project .repo , project .working_dir )
34- return HttpResponse (res )\
34+ return HttpResponse (res )
3535
3636@csrf_protect
3737def cloneCI (request ):
@@ -121,5 +121,85 @@ def deploy(request):
121121 "Dear User,<br/> This is an automated notification that a new version of %s has been deployed at: %s.<br>%s" % (
122122 project .name , link , changes_text ), fromUser = None , cc = "" , bcc = "" , )
123123 return HttpResponse (res + ",," + link )
124+ else :
125+ return HttpResponse (res )
126+
127+ @csrf_protect
128+ def integrate (request ):
129+ from webapp .autoDeploy .autoDeploy import Common
130+ server = CDModels .Server .objects .get (name = request .session ["integrate_server" ])
131+ project = CIModels .Project .objects .get (name = request .session ["integrate_project" ])
132+ last_Integration = None
133+ try :
134+ last_Integration = CIModels .Integration_server .objects .filter (server = server , project = project ).latest ()
135+ except :
136+ pass
137+ D = CIModels .Integration_server ()
138+ c = Client (str (project .repo_type ), server .ip , server .port )
139+ D .project = project
140+ D .server = server
141+ if "tag" in request .GET :
142+ res = c .SwitchTag (project .working_dir , request .GET ["tag" ])
143+ D .update_type = "tag"
144+ D .update_version = request .GET ["tag" ]
145+ project .lastTag = request .GET ["tag" ]
146+ elif "commit" in request .GET :
147+ if request .GET ["commit" ] != "HEAD" :
148+ res = c .SwitchCommit (project .working_dir , request .GET ["commit" ])
149+ D .update_type = "commit"
150+ D .update_version = request .GET ["commit" ]
151+ project .lastCommit = request .GET ["commit" ]
152+ res = c .Integrate (project .working_dir , project .configFile )
153+ if not "ERR:" in res :
154+ D .datetime = timezone .now ()
155+ D .has_new_version = False
156+ D .save ()
157+ project .lastUpdate = timezone .now ()
158+ project .newVersion = False
159+ project .save ()
160+ print (project .integration_link )
161+ if not "http://" in project .integration_link :
162+ print ("in if" )
163+ link = "http://" + server .DNS + project .integration_link
164+ print (link )
165+ if project .emailUsers != "" or project .emailUsers != " " and last_Integration != None :
166+ changes = c .getChangeLog (project .working_dir , since = last_Integration .update_version ,
167+ to = request .GET ["commit" ])
168+ changes_text = "<h3>Changes</h3><ul>"
169+ found = False
170+ for change in changes :
171+ if change .endswith (":" ): continue
172+ changes_text += "<li>%s</li>" % change
173+ found = True
174+ if found :
175+ changes_text += "</ul>"
176+ else :
177+ changes_text = ""
178+ Common .send (project .emailUsers .replace ("," , ";" ), "New version of %s integrated" % project .name ,
179+ "Dear User,<br/> This is an automated notification that a new version of %s has been integrated at: %s<br/>%s" % (
180+ project .name , link , changes_text ), fromUser = None , cc = "" , bcc = "" , )
181+
182+ return HttpResponse (res + ",," + link )
183+ else :
184+ print ("in else" )
185+ link = project .integration_link
186+ if project .emailUsers != "" or project .emailUsers != " " :
187+ changes = c .getChangeLog (project .working_dir , since = last_Integration .update_version ,
188+ to = request .GET ["commit" ])
189+ changes_text = "<h3>Changes</h3><ul>"
190+ found = False
191+ for change in changes :
192+ if change .endswith (":" ): continue
193+ changes_text += "<li>%s</li>" % change
194+ found = True
195+ if found :
196+ changes_text += "</ul>"
197+ else :
198+ changes_text = ""
199+
200+ Common .send (project .emailUsers .replace ("," , ";" ), "New version of %s integrated" % project .name ,
201+ "Dear User,<br/> This is an automated notification that a new version of %s has been integrated at: %s.<br>%s" % (
202+ project .name , link , changes_text ), fromUser = None , cc = "" , bcc = "" , )
203+ return HttpResponse (res + ",," + link )
124204 else :
125205 return HttpResponse (res )
0 commit comments