diff --git a/public_html/deployment/act_deploy.php b/public_html/deployment/act_deploy.php index 319238f63c7b4b7e38639e84108372f9814bbaab..54f8e320c9a8a16894b6d2ea4f8183e38e65a66f 100644 --- a/public_html/deployment/act_deploy.php +++ b/public_html/deployment/act_deploy.php @@ -1,63 +1,74 @@ -<?php -/* ###################################################################### - - IML DEPLOYMENT - - webgui - deploy th package of the queue to repo - - --------------------------------------------------------------------- - 2013-11-08 Axel <axel.hahn@iml.unibe.ch> - ###################################################################### */ - -require_once("./config/inc_projects_config.php"); -require_once("./classes/project.class.php"); -require_once("./inc_functions.php"); - - -// --- Checks -$oPrj=new project($aParams["prj"]); - - -$sOut=''; -if (array_key_exists("par3", $aParams)){ - $sPhase=$aParams["par3"]; -} - - -if (array_key_exists("confirm", $aParams)) { - $sOut.=$oPrj->deploy($sPhase); -} else { - if ($sPhase){ - $sPhase=$aParams["par3"]; - - $aPhaseData=$oPrj->getPhaseInfos($sPhase); - - $sOut.=' - <p> - in der Queue:<br> - '.$oPrj->renderPhaseDetail($sPhase, "onhold", false).' - </p> - '; - - // Eingabe Kommentare zum Deployment - $sOut.=' - - <form action="?" method="post" enctype="multipart/form-data"> - <input type="hidden" name="confirm" value="1"> - <fieldset> - <button type="submit" class="btn btn-primary btn-large" >Deploy</button> - </fieldset> - </form> - '; - } else { - $sOut.=getBox("error", 'ERROR: missing name of the phase.'); - } -} - - -$sOut.='<hr>'.aPrjHome(); - - -// -- Ausgabe -$sPhpOut=$sOut; -?> +<?php + +/* ###################################################################### + + IML DEPLOYMENT + + webgui - deploy th package of the queue to repo + + --------------------------------------------------------------------- + 2013-11-08 Axel <axel.hahn@iml.unibe.ch> + ###################################################################### */ + +require_once("./config/inc_projects_config.php"); +require_once("./classes/project.class.php"); +require_once("./inc_functions.php"); + + +// --- Checks +$oPrj = new project($aParams["prj"]); + + +$sOut = ''; +if (array_key_exists("par3", $aParams)) { + $sPhase = $aParams["par3"]; +} + + +if (array_key_exists("confirm", $aParams)) { + $bIgnoreDeploytimes = false; + if (array_key_exists("bIgnoreDeploytimes", $aParams)) { + $bIgnoreDeploytimes = $aParams["bIgnoreDeploytimes"]; + } + $sOut.=$oPrj->deploy($sPhase, $bIgnoreDeploytimes); +} else { + if ($sPhase) { + $sPhase = $aParams["par3"]; + + $aPhaseData = $oPrj->getPhaseInfos($sPhase); + + $sOut.=' + <p> + in der Queue:<br> + ' . $oPrj->renderPhaseDetail($sPhase, "onhold", false) . ' + </p> + '; + + // Eingabe Kommentare zum Deployment + $sOut.=' + + <form action="?" method="post" enctype="multipart/form-data"> + <input type="hidden" name="confirm" value="1"> + <fieldset> + <strong>Nur für für Notfälle:</strong><br> + <input type="checkbox" name="bIgnoreDeploytimes" value="1"> Deploy-Zeitfenster ignorieren.<br> + Nicht jedes Update muss sauber durchlaufen. Nur aktivieren, wenn + einer der Entwickler und/ oder ein Sysadmin zur Hand ist.<br> + </fieldset><br> + <fieldset> + <button type="submit" class="btn btn-primary btn-large" >Deploy</button> + </fieldset> + </form> + '; + } else { + $sOut.=getBox("error", 'ERROR: missing name of the phase.'); + } +} + + +$sOut.='<hr>' . aPrjHome(); + + +// -- Ausgabe +$sPhpOut = $sOut; +?> diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index 02d841dba6382abbec0e17c9192803db199747f4..dafda7fbc6a868ad8c16719f81375ce4ce0689fd 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -1034,9 +1034,10 @@ class project { * and will be installed on server within 30 min. * This method checks the deploy times * @param string $sPhase which queue of which phase we want to install in server + * @param bool $bIgnoreDeploytimes flag; if true it will override time windows * @return boolean|string */ - public function deploy($sPhase) { + public function deploy($sPhase, $bIgnoreDeploytimes=false) { $sReturn = "<h2>Deploy " . $this->getLabel() . " to $sPhase</h2>"; if (!$this->isActivePhase($sPhase)) { @@ -1063,10 +1064,15 @@ class project { $sReturn.="<br>"; } if (!$bCanDeploy) { - $sReturn.=$this->getBox("info", "SKIP: Im Moment ist leider kein Deployment-Zeitfenster"); - return $sReturn; + if (!$bIgnoreDeploytimes) { + $sReturn.=$this->getBox("info", "SKIP: Im Moment ist leider kein Deployment-Zeitfenster"); + return $sReturn; + }else { + $sReturn.="Im Moment ist leider kein Deployment-Zeitfenster - aber das wird ignoriert.<br>"; + } + } else { + $sReturn.="OK, wir sind im erforderlichen Zeitfenster.<br>"; } - $sReturn.="OK, deployment time was reached.<br>"; // if () } if (!file_exists($sQueueLink)) { @@ -1459,10 +1465,12 @@ class project { switch ($sPlace) { case "onhold": - if (array_key_exists($sPhase, $this->_aConfig)) { - $sReturn .= print_r($this->_aConfig[$sPhase], true); - if (array_key_exists("deploytimes", $this->_aConfig[$sPhase])) { - $sReturn .= '<br><i class="icon-time"></i> Deployment:<br>' . implode("<br>", array_values($this->_aPhases[$sPhase]["deploytimes"])); + if (array_key_exists("phases", $this->_aConfig) && array_key_exists($sPhase, $this->_aConfig["phases"])) { + // $sReturn .= print_r($this->_aConfig["phases"][$sPhase], true); + if (array_key_exists("deploytimes", $this->_aConfig["phases"][$sPhase])) { + $sReturn .= '<br><i class="icon-time"></i> Deployment:<br>' + . implode("<br>", array_values($this->_aConfig["phases"][$sPhase]["deploytimes"])) + . '<br>'; } if ($bActions) { $sReturn .= $this->renderLink("deploy", $sPhase); diff --git a/public_html/deployment/config/inc_projects_config.php b/public_html/deployment/config/inc_projects_config.php index 488c36ac39900820cd48cc5a82fd1a47d2845129..0b77fce1f371063c30d169705b5e5516a4ff1014 100644 --- a/public_html/deployment/config/inc_projects_config.php +++ b/public_html/deployment/config/inc_projects_config.php @@ -1,68 +1,66 @@ -<?php - - -// ---------------------------------------------------------------------- -// fetch status infos von den einzelnen Phasen -// ---------------------------------------------------------------------- - -$aConfig=array( - - // Basispfad: - 'workDir'=>'/var/imldeployment', - 'versionsToKeep'=>10, // for cleanup: keep n unused versions - 'builtsToKeep'=>3, // for cleanup: keep n failed builds - 'hooks'=>array( - 'build-aftercheckout'=>'hooks/onbuild', - ), - - // rsync of archives - 'mirrorPackages'=>array( - 'puppet'=>array( - 'type'=>'rsync', - 'runas'=>'www-data', // nur fuer commandline - 'target'=>'ladmin@calcium.iml.unibe.ch:/share/imldeployment', - ), - ), - - - 'phases'=>array( - "preview"=>array( - ), - "stage"=>array( - /* - "deploytimes"=>array( - '/(Mon|Tue|Wed|Thu)\ 15\:0/', - ), - */ - ), - "live"=>array( - // wenn deploytimes existiert, dann wird nach dem Deploy das Paket - // in einer Queue zurueckgehalten - "deploytimes"=>array('/(Mon|Tue|Wed|Thu)\ 14\:/'), - ), - ), -); - -// ---------------------------------------------------------------------- -// override for local development -// ---------------------------------------------------------------------- - -if ($_SERVER && array_key_exists("SERVER_NAME", $_SERVER)){ - switch ($_SERVER["SERVER_NAME"]) { - case "localhost": - case "dev.ci.iml.unibe.ch": - $aConfig['workDir']="D:\imldeployment"; - $aProjects["scrudu"]["phases"]["preview"]["url"]="http://localhost/deployment/"; - break; - - default: - break; - } -} - -$aConfig=array_merge($aConfig, array( - 'buildDir'=>$aConfig['workDir'].'/build', - 'buildDefaultsDir'=>$aConfig['workDir'].'/defaults', - 'packageDir'=>$aConfig['workDir'].'/packages', - 'archiveDir'=>$aConfig['workDir'].'/packages/_files', -)); +<?php + + +// ---------------------------------------------------------------------- +// fetch status infos von den einzelnen Phasen +// ---------------------------------------------------------------------- + +$aConfig=array( + + // Basispfad: + 'workDir'=>'/var/imldeployment', + 'versionsToKeep'=>10, // for cleanup: keep n unused versions + 'builtsToKeep'=>3, // for cleanup: keep n failed builds + 'hooks'=>array( + 'build-aftercheckout'=>'hooks/onbuild', + ), + + // rsync of archives + 'mirrorPackages'=>array(), + + + 'phases'=>array( + "preview"=>array(), + "stage"=>array(), + "live"=>array( + // wenn deploytimes existiert, dann wird nach dem Deploy das Paket + // in einer Queue zurueckgehalten + "deploytimes"=>array('/(Mon|Tue|Wed|Thu)\ 14\:/'), + ), + ), +); + +// ---------------------------------------------------------------------- +// override for local development +// ---------------------------------------------------------------------- + +if ($_SERVER && array_key_exists("SERVER_NAME", $_SERVER)){ + switch ($_SERVER["SERVER_NAME"]) { + case "localhost": + case "dev.ci.iml.unibe.ch": + $aConfig['workDir']="D:\imldeployment"; + $aProjects["scrudu"]["phases"]["preview"]["url"]="http://localhost/deployment/"; + break; + + case "ci.iml.unibe.ch": + + // synch der Pakete nur auf dem Livesystem + $aConfig['mirrorPackages']=array( + 'puppet'=>array( + 'type'=>'rsync', + 'runas'=>'www-data', // nur fuer commandline + 'target'=>'ladmin@calcium.iml.unibe.ch:/share/imldeployment', + )); + break; + + default: + break; + } +} + +$aConfig=array_merge($aConfig, array( + 'buildDir'=>$aConfig['workDir'].'/build', + 'buildDefaultsDir'=>$aConfig['workDir'].'/defaults', + 'packageDir'=>$aConfig['workDir'].'/packages', + 'archiveDir'=>$aConfig['workDir'].'/packages/_files', +));