Skip to content

Commit

Permalink
• Moved cake to the root of the Azure PaaS folder. This was done beca…
Browse files Browse the repository at this point in the history
…use we needed to tie the various user input scripts together before launching the build.ps1. My options were to write an argument builder for the build.ps1, or just move the build.ps1 and edit it a very little bit.

• Adjusted the build.cake for the cake location move.
• Adjusted git.ignore for the cake location move
• Adjusted Readme.md with an accurate and current process

Current Known Bugs:
• If you try to include verbosity along with a target it tell you “More than one build script specified” this is apparently an issue with cake: cake-build/cake-vscode#85
• The Upload script fails in cake for some reason I haven’t investigated at all, might be a simple fix idk yet
  • Loading branch information
keith0123 committed Oct 10, 2018
1 parent c945838 commit 30fb2b1
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ packages/
tools/*
!tools/packages.config

/Azure PaaS/Cake/tools/*
!/Azure PaaS/Cake/tools/packages.config
/Azure PaaS/tools/*
!/Azure PaaS/tools/packages.config
File renamed without changes.
6 changes: 4 additions & 2 deletions Azure PaaS/HelperScripts/AzureUser-Config-Capture.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if (!$azureuserconfig) {
########################
# Get Azure Credentials
########################
<#

Write-Host "Importing and Installing AzureRm Module"

$AzureModule = Get-Module -ListAvailable AzureRM
Expand All @@ -64,11 +64,13 @@ Import-Module AzureRM
Enable-AzureRmContextAutosave

Add-AzureRmAccount
#>

###########################################
# Get User Input for azureuser-config.json
###########################################

Write-host "Please Enter Azure Settings"

foreach ($setting in $azureuserconfig.settings)
{
switch ($setting.id)
Expand Down
21 changes: 12 additions & 9 deletions Azure PaaS/HelperScripts/Env-Prep.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<#
.SYNOPSIS
Prepare Local environnment for habitat home scwdp package creation
.DESCRIPTION
This script will check the local Deploy folder defined in the cake-config.json file for an Assets folder, and create one if it doesn't exist.
It will then check the folder for prerequisite files as defined by the assets.json.
The script will then download anything missing and extract tools so they can be used by later scripts.
The script will then download anything missing and extract tools and files so they can be used by later scripts.
#>

Param(
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $ConfigurationFile,
[Parameter(Mandatory=$true)]
[Parameter(Mandatory=$true, HelpMessage="Please Enter your dev.sitecore.com username")]
[ValidateNotNullOrEmpty()]
[string] $Username,
[Parameter(Mandatory=$true)]
[string] $SitecoreDownloadUsername,
[Parameter(Mandatory=$true, HelpMessage="Please Enter your dev.sitecore.com password")]
[ValidateNotNullOrEmpty()]
[Security.SecureString] $Password
[Security.SecureString] $SitecoreDownloadPassword
)

###########################
Expand Down Expand Up @@ -61,7 +65,7 @@ $foundfiles = New-Object System.Collections.ArrayList
$downloadlist = New-Object System.Collections.ArrayList
$assetsfolder = (Join-Path $config.DeployFolder assets)
[string] $habitathomefilepath = $([io.path]::combine($config.DeployFolder, 'Website', 'HabitatHome'))
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $Password
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $SitecoreDownloadUsername, $SitecoreDownloadPassword

##################################################
# Check for existing Files in Deploy\Assets Folder
Expand Down Expand Up @@ -160,8 +164,6 @@ else
# Download Required Files
###########################

Import-Module "$($PSScriptRoot)\DownloadFileWithCredentials\DownloadFileWithCredentials.psm1" -Force

Function Download-Asset {
param( [PSCustomObject]
$assetfilename,
Expand All @@ -188,7 +190,8 @@ else
Assetfilename = $assetfilename
TypeSource = $sourceType
}

Import-Module "$($PSScriptRoot)\DownloadFileWithCredentials\DownloadFileWithCredentials.psm1" -Force

Invoke-DownloadFileWithCredentialsTask @params

}
Expand Down
7 changes: 1 addition & 6 deletions Azure PaaS/HelperScripts/Generate-HabitatUpdatePackages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Function Process-UpdatePackage([PSObject] $Configuration, [String] $FolderString

$updateFile = Join-Path $([IO.Path]::Combine($Configuration.DeployFolder, 'assets', $targetFolderName)) "$($targetFolderName).update"
$courierPath = $([IO.Path]::Combine($Configuration.DeployFolder, 'assets', 'Sitecore Courier'))
GenerateUpdatePackage -pathToCourier "$($courierPath)\Sitecore.Courier.Runner.exe" -configFile $Configuration -argSourcePackagingFolder $sourceFolder -argOutputPackageFile $updateFile
GenerateUpdatePackage -configFile $Configuration -argSourcePackagingFolder $sourceFolder -argOutputPackageFile $updateFile

}

Expand All @@ -58,18 +58,13 @@ Function Process-UpdatePackage([PSObject] $Configuration, [String] $FolderString
Function GenerateUpdatePackage(){

Param(
[parameter(Mandatory=$true)]
[String] $pathToCourier,
[parameter(Mandatory=$true)]
[String] $configFile,
[String] $argSourcePackagingFolder,
[String] $argOutputPackageFile

)


# heres the code for the powershell module version of courier if we want to use that in the future

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name Sitecore.Courier

Expand Down
12 changes: 6 additions & 6 deletions Azure PaaS/HelperScripts/Upload-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ Function UploadWDPs ([PSCustomObject] $cakeConfigFile, [PSCustomObject] $assetsC

# Upload Habitat WDPs

$habitatWebsiteWDPPath = [IO.Path]::Combine($assetsFolder, 'website', 'convert to WDP', 'WDP', 'website_single.scwdp.zip')
$habitatWebsiteWDPPath = [IO.Path]::Combine($assetsFolder, 'habitathome', 'convert to WDP', 'WDP', 'habitathome_single.scwdp.zip')
if((Test-Path $habitatWebsiteWDPPath) -eq $True){

$habitatWebsiteWDPFile = Get-Item -Path $habitatWebsiteWDPPath
Expand Down Expand Up @@ -212,7 +212,7 @@ Function UploadFiles ([PSCustomObject] $cakeConfigFile){
$azuredeployArmTemplate = Get-Item -Path $([IO.Path]::Combine($config.ProjectFolder, 'Azure Paas', 'XP0 Single', 'azuredeploy.json'))
$sxaArmTemplate = Get-Item -Path $([IO.Path]::Combine($config.ProjectFolder, 'Azure Paas', 'ARM Templates', 'Modules', 'Sitecore Experience Accelerator', 'sxa_module.json'))
$defArmTemplate = Get-Item -Path $([IO.Path]::Combine($config.ProjectFolder, 'Azure Paas', 'ARM Templates', 'Modules', 'Data Exchange Framework', 'def_module.json'))
$habitatWebsiteArmTemplate = Get-Item -Path $([IO.Path]::Combine($config.ProjectFolder, 'Azure Paas', 'ARM Templates', 'Habitat', 'website.json'))
$habitatWebsiteArmTemplate = Get-Item -Path $([IO.Path]::Combine($config.ProjectFolder, 'Azure Paas', 'ARM Templates', 'Habitat', 'habitathome.json'))
$habitatXconnectArmTemplate = Get-Item -Path $([IO.Path]::Combine($config.ProjectFolder, 'Azure Paas', 'ARM Templates', 'Habitat', 'xconnect.json'))
$bootloadArmTemplate = Get-Item -Path $([IO.Path]::Combine($config.ProjectFolder, 'Azure Paas', 'XP0 Single', 'addons', 'bootloader.json'))

Expand Down Expand Up @@ -307,7 +307,7 @@ $originalContainerName = "azure-toolkit"
$additionalContainerName = "temporary-toolkit"



<#
# Check the Azure PowerShell Module's version
$AzureModule = Get-Module -ListAvailable AzureRM
if ($AzureModule -eq ""){
Expand All @@ -324,7 +324,7 @@ Import-Module AzureRM
Enable-AzureRmContextAutosave
Add-AzureRmAccount

#>
# Connect to Azure with an interactive dialog for sign-in
#Connect-AzureRmAccount

Expand Down Expand Up @@ -475,7 +475,7 @@ ForEach($blob in $blobsList){
$xcSingleMsDeployPackageUrl = (Get-AzureStorageBlob -Blob $blob.Name -Container $containerName -Context $ctx).ICloudBlob.uri.AbsoluteUri

}
"wdps/website_single.scwdp.zip"
"wdps/habitathome_single.scwdp.zip"
{

$habitatWebsiteDeployPackageUrl = (Get-AzureStorageBlob -Blob $blob.Name -Container $containerName -Context $ctx).ICloudBlob.uri.AbsoluteUri
Expand Down Expand Up @@ -509,7 +509,7 @@ ForEach ($blob in $blobsList){

$defTemplateLink = (Get-AzureStorageBlob -Blob $blob.Name -Container $containerName -Context $ctx).ICloudBlob.uri.AbsoluteUri

} elseif($blob.Name -like "*website.json"){
} elseif($blob.Name -like "*habitathome.json"){

$habitatWebsiteTemplateLink = (Get-AzureStorageBlob -Blob $blob.Name -Container $containerName -Context $ctx).ICloudBlob.uri.AbsoluteUri

Expand Down
51 changes: 37 additions & 14 deletions Azure PaaS/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,48 @@ The following is a list of default values/assumptions for install locations
**Project Folder** `c:\projects\sitecore.habitathome.content\`
**Deploy Folder** `c:\Deploy`

if these values are not correct you will need to edit the cake-config.json in the `\Azure PaaS\Cake` folder.
if these values are not correct you will need to edit the cake-config.json in the `\Azure PaaS` folder.

### 3. Environment Preparation
### 3. Deploy Sitecore.HabitatHome.Content

From the `Sitecore.HabitatHome.Content\Azure PaaS\HelperScripts` folder

- Run **`Env-Prep.ps1 -ConfigurationFile "See Below"`**

For the `-ConfigurationFile` parameter please provde the full path to the `cake-config.json` located in your `\Azure PaaS\Cake folder`

This will prompt you for your dev.sitecore.com username and password.

### 4. Deploy Sitecore.HabitatHome.Content

From the `\Azure PaaS\Cake` folder
From the `\Azure PaaS` folder

- Run **`.\build.ps1`**

### 5. Validating deployment
Optional Parameters:
|Parameter | Description
|-------------------------------------------|---------------------------------------------------------------------------------------------
| Verbosity | Specifies the amount of information to be displayed
| ShowDescription | Shows description about tasks.
| DryRun | Performs a dry run.
| SkipToolPackageRestore | Skips restoring of packages.
| Target | Build Target **(see below)**

**Target**
|Value | Description
|-------------------------------------------|---------------------------------------------------------------------------------------------
| Default | Same affect as no target defined, will build and deploy to Azure.
| Build | Create build output only, will **not** upload or deploy to Zzure
| Azure-Upload | Performs only the upload to Azure portion of the process
| Azure-Deploy | Performs only the Deployment portion of the process

##### Environment Preparation

This script will prompt you for information regarding your build and deployment

|Parameter | Description
|-------------------------------------------|---------------------------------------------------------------------------------------------
| SitecoreDownloadUsername | dev.sitecore.com username
| SitecoreDownloadPassword | dev.sitecore.com password
| AzureDeploymentID | Resource group name.
| AzureRegion | The geographical region of the current deployment.
| SitecoreLoginAdminPassword | The new password for the Sitecore **admin** account. (8 Character Minimum)
| SqlServerLoginAdminAccount | The name of the administrator account for Azure SQL server that will be created. SA is not a valid login
| SqlServerLoginAdminPassword | The password for the administrator account for Azure SQL server.
| XConnectCertfilePath | A Base64-encoded blob of the authentication certificate in PKCS #12 format.
| XConnectCertificatePassword | A password to the authentication certificate.

### 4. Validating deployment

##### The hostname habitathome.dev.local is used in the SXA Hostname (Site Grouping).

Expand Down
2 changes: 1 addition & 1 deletion Azure PaaS/XP0 Single/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Instructions

Please follow the instructions on the [Azure PaaS Readme](Azure PaaS/Readme.md)
Please follow the instructions on the [Azure PaaS Readme](../Readme.md)

## Resources provisioned:

Expand Down
43 changes: 32 additions & 11 deletions Azure PaaS/Cake/build.cake → Azure PaaS/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,33 @@ Task("Default")
//.IsDependentOn("Rebuild-Master-Index")
//.IsDependentOn("Rebuild-Web-Index")
.IsDependentOn("Publish-YML")
.IsDependentOn("Package-Build")
.IsDependentOn("Azure-Upload-Packages")
.IsDependentOn("Azure-Site-Deploy");

Task("Build")
.WithCriteria(configuration != null)
.IsDependentOn("Clean")
.IsDependentOn("Publish-All-Projects")
.IsDependentOn("Apply-Xml-Transform")
.IsDependentOn("Publish-Transforms")
.IsDependentOn("Publish-xConnect-Project")
//.IsDependentOn("Deploy-EXM-Campaigns")
//.IsDependentOn("Deploy-Marketing-Definitions")
//.IsDependentOn("Rebuild-Core-Index")
//.IsDependentOn("Rebuild-Master-Index")
//.IsDependentOn("Rebuild-Web-Index")
.IsDependentOn("Publish-YML")
.IsDependentOn("Package-Build");

Task("Azure-Upload")
.WithCriteria(configuration != null)
.IsDependentOn("Azure-Upload-Packages");

Task("Azure-Deploy")
.WithCriteria(configuration != null)
.IsDependentOn("Azure-Site-Deploy");

/*===============================================
================= SUB TASKS =====================
===============================================*/
Expand Down Expand Up @@ -149,7 +174,7 @@ Task("Publish-YML").Does(() => {

StartPowershellFile (($"{configuration.ProjectFolder}\\Azure PaaS\\HelperScripts\\Publish-YML.ps1"), args =>
{
args.AppendQuoted($"{configuration.ProjectFolder}\\Azure PaaS\\Cake\\cake-config.json");
args.AppendQuoted($"{configuration.ProjectFolder}\\Azure PaaS\\cake-config.json");
});
});

Expand All @@ -160,32 +185,28 @@ Task("Package-Build")
Task("Generate-HabitatUpdatePackages").Does(() => {
StartPowershellFile ($"{configuration.ProjectFolder}\\Azure PaaS\\HelperScripts\\Generate-HabitatUpdatePackages.ps1", args =>
{
args.AppendQuoted($"{configuration.ProjectFolder}\\Azure PaaS\\Cake\\cake-config.json");
args.AppendQuoted($"{configuration.ProjectFolder}\\Azure PaaS\\cake-config.json");
});
});

Task("ConvertTo-SCWDPs").Does(() => {
StartPowershellFile ($"{configuration.ProjectFolder}\\Azure PaaS\\HelperScripts\\ConvertTo-SCWDPs.ps1", args =>
{
args.AppendQuoted($"{configuration.ProjectFolder}\\Azure PaaS\\Cake\\cake-config.json");
args.AppendQuoted($"{configuration.ProjectFolder}\\Azure PaaS\\cake-config.json");
});
});

Task("Azure-Deploy")
.IsDependentOn("Upload-Packages")
.IsDependentOn("Site-Deploy");

Task("Upload-Packages").Does(() => {
Task("Azure-Upload-Packages").Does(() => {
StartPowershellFile ($"{configuration.ProjectFolder}\\Azure PaaS\\HelperScripts\\Upload-Packages.ps1", args =>
{
args.AppendQuoted($"{configuration.ProjectFolder}\\Azure PaaS\\Cake\\cake-config.json");
args.AppendQuoted($"{configuration.ProjectFolder}\\Azure PaaS\\cake-config.json");
});
});

Task("Site-Deploy").Does(() => {
Task("Azure-Site-Deploy").Does(() => {
StartPowershellFile ($"{configuration.ProjectFolder}\\Azure PaaS\\HelperScripts\\Azure-Deploy.ps1", args =>
{
args.AppendQuoted($"{configuration.ProjectFolder}\\Azure PaaS\\Cake\\cake-config.json");
args.AppendQuoted($"{configuration.ProjectFolder}\\Azure PaaS\\cake-config.json");
});
});

Expand Down
16 changes: 16 additions & 0 deletions Azure PaaS/Cake/build.ps1 → Azure PaaS/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ https://cakebuild.net
[CmdletBinding()]
Param(
[string]$Script = "build.cake",
[ValidateSet("Default", "Build", "Azure-Upload", "Azure-Deploy")]
[string]$Target,
[string]$Configuration,
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
Expand All @@ -50,6 +51,21 @@ Param(
[string[]]$ScriptArgs
)

###############################
# Run AzureUser-Config-Capture
###############################

if(($Target) -and ($Target -ne "Build") -or !($Target))
{
& ".\\HelperScripts\AzureUser-Config-Capture.ps1" -ConfigurationFile "cake-config.json"
}

###############################
# Run Env-Prep
###############################

& ".\\HelperScripts\Env-Prep.ps1" -ConfigurationFile "cake-config.json"

# Attempt to set highest encryption available for SecurityProtocol.
# PowerShell will not set this by default (until maybe .NET 4.6.x). This
# will typically produce a message for PowerShell v2 (just an info
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 30fb2b1

Please sign in to comment.