Script:- ETL_Automated_deployment.ps1

$content = Get-Content “D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\ETL_Deployment_Groups_List.txt”
foreach ($line in $content)
{
$INFA_PWD=$ENV:INFA_PASSWD
$INFA_PWD_TST=$ENV:INFA_PASSWD_TST

$Src_Usr = “XXX”
$Src_Pwd = “XXX”
$Tgt_Usr= “XXX”
$Tgt_Pwd= “XXX”
$Src_Dom= “DOM961_ETLDV”
$Src_Repo = “XXXX_REP961_ETLDV”
$Tgt_Dom = “DOM961_ETLTS”
$Tgt_Repo = “XXX_REP961_ETLTS”
$Impacted_Query = “AFTER_DEPLOY_QUERY”
$Input_File = “D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\ETL_Deployment_Groups_List.txt”
$Ctrl_File = “D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DeployOptions.xml”
$LogLocation = “D:\Informatica\9.6.1\server\infa_shared\log\AUTOMATED_DEPLOY_LOGS”
$FILE_NAME = $line +”_Log.txt”
$OutputFileLocation = “$LogLocation\$FILE_NAME”

Remove-Item $LogLocation\*
if ($? -ne “True”)
{
write-host “unable to remove the log file”
}
# define logwrite function
write-host “Log’s are available at this path $OutputFileLocation ”
Function LogWrite
{
Param ([string]$logstring)
$date=Get-Date
Write-Output “$date : $logstring” | Out-File $OutputFileLocation -Append
}

#Create DeploymentScript_Log.txt log file

New-Item $LogLocation\$FILE_NAME -type file -force

if ($? -ne “True”)
{
LogWrite “”
LogWrite “Creation of the file DeploymentScript_Log.txt has failed”
LogWrite “”
exit -3
}
# changing the directory to bin location.

Push-Location -Path “\\XXXXXX\D$\Informatica\9.6.1\Server\bin”

if ($? -ne “True”)
{
LogWrite “”
LogWrite “Unable to change the directory to bin”
LogWrite “”
exit -3
}

LogWrite “————–STEP 1—————–” n`
LogWrite “Connecting to the source repository …” n`
LogWrite “———————————————-” n`

pmrep connect -r $Src_Repo -d $Src_Dom -n Administrator -X INFA_PM_PASSWD -s Native >> $OutputFileLocation

if ($? -ne “True”)
{
LogWrite “Execution of first pmrep to connect $Src_Repo is un-successful.” `n
LogWrite “”
LogWrite “———————————————”
LogWrite “A Failure email notification will be send.”
LogWrite “———————————————”
D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_Failure_email.ps1 “$line”

if ($? -ne “True”)
{
LogWrite “”
LogWrite ” Unable to execute the email task” `n
LogWrite “The email script path is D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_Failure_email.ps1”
LogWrite “”
exit -3
}
exit -3
}

# ——————————————–
# ****************** STEP 2 ******************
# Connect to the Target repository ….
# ——————————————–
LogWrite “”
LogWrite “————–STEP 2—————-”
LogWrite “Connecting to the target repository $Tgt_Repo to execute the reployment group.”
LogWrite “———————————————–” `n”$FILE_NAME”

$DeploymentGroup_Status = $line + “_DeploymentGroup_Status.txt”

pmrep deploydeploymentgroup -p $line -c $Ctrl_File -r $Tgt_Repo -n Administrator -X INFA_PM_PASSWD_TS -s Native -d $Tgt_Dom -l “$LogLocation\$DeploymentGroup_Status” >> $OutputFileLocation

if ($? -ne “True”)
{
LogWrite ” Execution of deploydeploymentgroup $Input_File is un-successful… Please check the connectitivy to the target repository $Tgt_Repo” `n
LogWrite ” Please check step 2 section in the script … ” `n
LogWrite “”
LogWrite “———————————————”
LogWrite “A Failure email notification will be send.”
LogWrite “———————————————”

D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_Failure_email.ps1 “$line”

if ($? -ne “True”)
{
LogWrite “”
LogWrite ” Unable to execute the email task” `n
LogWrite “The email script path is D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_Failure_email.ps1”
LogWrite “”
exit -3
}
exit -3
}

if ($? -eq “True”)
{
LogWrite “”
LogWrite “Execution of deploydeploymentgroup is successful…”
LogWrite “”
}
# ———————————————————————————————————————
# ****************** STEP 3 ******************
# After deployment checking for any impacted objects. If any object impacted the script will log the details in the log directory for review purpose.
# This script will automatically validated all the impacted objects..
# ———————————————————————————————————————–

LogWrite “——————-STEP 3——————-”
LogWrite “”
LogWrite “”
pmrep connect -r $Tgt_Repo -n $Tgt_Usr -x $Tgt_Pwd -d $Tgt_Dom >> $OutputFileLocation
LogWrite “”

if ($? -ne “True”)
{ LogWrite “Unable to connect to Target Repo !Tgt_Repo! to get the Impacted objects.”
LogWrite “Please check step 3 section in the script … ”
LogWrite “”
LogWrite “———————————————”
LogWrite “A Failure email notification will be send.”
LogWrite “———————————————”
D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_Failure_email.ps1 “$line”

if ($? -ne “True”)
{
LogWrite “”
LogWrite ” Unable to execute the email task” `n
LogWrite “The email script path is D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_Failure_email.ps1”
LogWrite “”
exit -3
}
exit -3
}

if ($? -eq “True”)
{ LogWrite “Successfuly connect to Target Repo $Tgt_Repo to get the Impacted objects details”
}

# ————————————————————————————-
# ************** STEP 4 *******************************************
# Impact query execution
#——————————————————————————

$Impacted_objects = $line + “_Impacted_objects.txt”

New-Item $LogLocation\$Impacted_objects -type file

LogWrite ” ”

LogWrite “Impacted objects File name is $Impacted_objects.”

LogWrite ” ”

pmrep executequery -q $Impacted_Query -u “$LogLocation\$Impacted_objects” >> $OutputFileLocation

if ($? -eq “True”)
{
LogWrite “”
LogWrite “execution of Impacted_objects.txt pmrep is successful.”
LogWrite “”
}

if ($? -ne “True”)
{
LogWrite ” Unable to execute the Impcated query .”
LogWrite “Please check step 4 section in the script.”
LogWrite “”
LogWrite “———————————————”
LogWrite “A Failure email notification will be send.”
LogWrite “———————————————”
D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_Failure_email.ps1 “$line”
LogWrite “”

if ($? -ne “True”)
{
LogWrite ” Unable to execute the email task” `n
LogWrite “The email script path is D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_Failure_email.ps1”
exit -3
}
exit -3
}

# ———————————————–
# ************** STEP 5 ******************
# Validation process starts at this step ….
# ———————————————-

$Validate_Object = $line + “_Validate_Object.log”

pmrep validate -i “$LogLocation\$Impacted_objects” -s -k -m Validate -p Valid,saved,skipped,save_failed,invalid_before,invalid_after > “$LogLocation\$Validate_Object”

if ($? -eq “True”)
{
LogWrite “”
LogWrite ” Validation process of the impacted objects is successful.”
LogWrite “”
LogWrite “———————————————”
LogWrite “ETL code deployment script has executed all the steps successfully.”
LogWrite “”
LogWrite “A success email notification will be send.”
LogWrite “———————————————”
D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_success_email.ps1 “$line”

if ($? -ne “True”)
{
LogWrite “”
LogWrite ” Unable to execute the email task” `n
LogWrite “The email script path is D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_Failure_email.ps1”
exit -3
}
exit
}
if ($? -ne “True”)
{
LogWrite “Validation process of the impacted objects is Un-successful.”
LogWrite “Please check step 5 section in the script.”
LogWrite “”
LogWrite “———————————————”
LogWrite “A Failure email notification will be send.”
LogWrite “———————————————”
D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_Failure_email.ps1 “$line”

if ($? -ne “True”)
{
LogWrite “”
LogWrite ” Unable to execute the email task” `n
LogWrite “The email script path is D:\Informatica\9.6.1\server\infa_shared\Scripts\ETL_CODE_DEPLOYMENT\DEPLOYMENT_SCRIPTS\Deployment_Failure_email.ps1”
exit -3
}
exit -3
}
}

Advertisements