prog:apex_export_source_code_and_git
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende Überarbeitung | |||
prog:apex_export_source_code_and_git [2018/03/10 09:10] – [Oracle Apex Source Code automatisch exportieren und einchecken mit Git unter Windows mit der PowerShell] gpipperr | prog:apex_export_source_code_and_git [2018/03/10 13:43] (aktuell) – [Script] gpipperr | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | =====Oracle Apex Source Code automatisch exportieren und einchecken mit Git unter Windows mit der PowerShell===== | ||
+ | **Aufgabe: | ||
+ | |||
+ | Zu Git siehe [[prog: | ||
+ | |||
+ | |||
+ | **Lösung: | ||
+ | |||
+ | Mit dem Hilfsprogramm **oracle.apex.APEXExport** lassen sich alle Elemente von Apex exportieren , mit **oracle.apex.APEXExportSplitter** läßt sich die Application in einzelne Elemente zerlegen. | ||
+ | |||
+ | |||
+ | **Ablauf im Script:** | ||
+ | |||
+ | - Falls noch kein Security Object für das Password hinterlegt ist, Password vom User abfragen | ||
+ | - Umgebung setzen | ||
+ | - Export des Workspaces | ||
+ | - Export der Instance | ||
+ | - Aufsplitten der Application in Einzelelemente | ||
+ | - Einchecken in GIT | ||
+ | |||
+ | |||
+ | Das besondere am folgenden Powershell Script ist das Password Handling. Das Password des Oracle Users ist nicht im Script enthalten. | ||
+ | |||
+ | Nach dem Anpassen der Parameter muss daher das Script einmalig über die Powershell interaktiv gestartet werden um das Passwort des Oracle Users zu hinterlegen. | ||
+ | |||
+ | Dazu wird das PSCredential Object verwendet, eine Dialog Box wird geöffent, das Objekt wird als XML File serialisiert und beim nächsten Start des Script wieder verwendet. | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | | ||
+ | === Script === | ||
+ | |||
+ | <code powershell backupApex.ps1> | ||
+ | # | ||
+ | # Author: Gunther Pippèrr ( http:// | ||
+ | # Desc: | ||
+ | # Date: March 2012 | ||
+ | # Site: | ||
+ | # | ||
+ | <# | ||
+ | .NOTES | ||
+ | Created: 03.2018 : Gunther Pippèrr (c) http:// | ||
+ | |||
+ | Security: | ||
+ | (see http:// | ||
+ | To switch it off (as administrator) | ||
+ | get-Executionpolicy -list | ||
+ | set-ExecutionPolicy -scope CurrentUser RemoteSigned | ||
+ | | ||
+ | .SYNOPSIS | ||
+ | Script to Backup APEX instance | ||
+ | |||
+ | .DESCRIPTION | ||
+ | Script to rScript to Backup APEX instance | ||
+ | |||
+ | .COMPONENT | ||
+ | Oracle Backup Script | ||
+ | |||
+ | .EXAMPLE | ||
+ | |||
+ | #> | ||
+ | |||
+ | # | ||
+ | |||
+ | |||
+ | |||
+ | # | ||
+ | # Helper Function to write log file and display message | ||
+ | ## | ||
+ | |||
+ | function local-print{ | ||
+ | # Parameters | ||
+ | Param( | ||
+ | [String] | ||
+ | , [String[]] $text | ||
+ | , [String[]] $errortext | ||
+ | |||
+ | ) | ||
+ | # End param | ||
+ | Begin {} | ||
+ | Process { | ||
+ | $backup_log = $log_file | ||
+ | # Message for the log | ||
+ | if ($errortext){ | ||
+ | $text=$errortext | ||
+ | $ForegroundColor = " | ||
+ | } | ||
+ | $log_message = (Get-Date -Format " | ||
+ | try { | ||
+ | write-host -ForegroundColor $ForegroundColor $text | ||
+ | # check if the file is accessible | ||
+ | try{ | ||
+ | $log_message | ||
+ | } | ||
+ | catch { | ||
+ | write-host -ForegroundColor " | ||
+ | } | ||
+ | } | ||
+ | catch { | ||
+ | throw "Error -- Failed to create log entry in: $backup_log. The error was: $_." | ||
+ | } | ||
+ | } | ||
+ | |||
+ | End {} | ||
+ | } | ||
+ | |||
+ | # Environment | ||
+ | |||
+ | $Invocation = (Get-Variable MyInvocation -Scope 0).Value | ||
+ | $scriptpath=Split-Path $Invocation.MyCommand.Path | ||
+ | |||
+ | $log_file=" | ||
+ | |||
+ | local-print -text "Info -- start the Script in the path $scriptpath" | ||
+ | |||
+ | # Runtime Parameter | ||
+ | |||
+ | $apex_util_dir = " | ||
+ | $ora_odbc_lib | ||
+ | $java_home | ||
+ | $git_home | ||
+ | $git_repos | ||
+ | |||
+ | # DB | ||
+ | $database=" | ||
+ | |||
+ | |||
+ | # PWD | ||
+ | $db_user | ||
+ | $oracle_credential = " | ||
+ | |||
+ | # | ||
+ | # To store the password we use the PSCredential object | ||
+ | # if the serialized object of the password not exists | ||
+ | # prompt the user to enter the password | ||
+ | # | ||
+ | |||
+ | if (!(test-path -path $oracle_credential)) { | ||
+ | $user_credential=GET-CREDENTIAL -credential " | ||
+ | export-clixml -InputObject $user_credential -Path $oracle_credential | ||
+ | } | ||
+ | else { | ||
+ | | ||
+ | } | ||
+ | |||
+ | #get the clear type password | ||
+ | |||
+ | $db_password=$user_credential.GetNetworkCredential().Password | ||
+ | |||
+ | # set the environment | ||
+ | |||
+ | set-item -path env: | ||
+ | set-item -path env: | ||
+ | set-item -path env: | ||
+ | |||
+ | # | ||
+ | # go to the git Repos | ||
+ | |||
+ | |||
+ | $repos_workspace=" | ||
+ | if (!(test-path -path $repos_workspace)) {new-item -path $repos_workspace -itemtype directory} | ||
+ | Set-Location $repos_workspace | ||
+ | |||
+ | # Export all Workspaces | ||
+ | & " | ||
+ | |||
+ | |||
+ | $repos_report=" | ||
+ | if (!(test-path -path $repos_report)) {new-item -path $repos_report -itemtype directory} | ||
+ | Set-Location $repos_report | ||
+ | |||
+ | # -expSavedReports | ||
+ | # & " | ||
+ | # | ||
+ | |||
+ | $repos_instance=" | ||
+ | if (!(test-path -path $repos_instance)) {new-item -path $repos_instance -itemtype directory} | ||
+ | Set-Location $repos_instance | ||
+ | |||
+ | # Export the Instance | ||
+ | |||
+ | & " | ||
+ | |||
+ | # alternativ Source Code exportieren only of one application | ||
+ | # java oracle.apex.APEXExport | ||
+ | |||
+ | |||
+ | # Split the Code | ||
+ | local-print -text "Info -- Split the files in $git_repos\instance" | ||
+ | |||
+ | # Loop over all sql Files | ||
+ | $sqlfiles = Get-ChildItem -Path " | ||
+ | |||
+ | for ($i=0; $i -lt $sqlfiles.Count; | ||
+ | # remove old not necessary | ||
+ | # Remove-Item -Path $sqlfiles[$i].BaseName -Recurse -Force | ||
+ | # Split the files | ||
+ | | ||
+ | & " | ||
+ | } | ||
+ | |||
+ | |||
+ | # | ||
+ | # GIT | ||
+ | |||
+ | Set-Location " | ||
+ | |||
+ | $datum = Get-Date | ||
+ | |||
+ | & " | ||
+ | & " | ||
+ | # Push to remote if exists | ||
+ | #& " | ||
+ | # Optimize database to avoid a too large db | ||
+ | & " | ||
+ | |||
+ | # go back home | ||
+ | |||
+ | Set-Location $scriptpath | ||
+ | |||
+ | ################### | ||
+ | </ | ||
+ | |||
+ | |||
+ | Aktuelle Version für die OraPowerShell unter https:// | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Quellen ==== | ||
+ | |||
+ | |||
+ | Oracle: | ||
+ | |||
+ | * Application Express App Builder User's Guide => https:// | ||
+ | * https:// | ||
+ | |||
+ | |||
+ | Powershell: | ||
+ | |||
+ | * https:// | ||
+ | * https:// |
prog/apex_export_source_code_and_git.txt · Zuletzt geändert: 2018/03/10 13:43 von gpipperr