- Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Architecture
- Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Step 1: Customize the TFS workflow
- Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Step 2: Configure TFS
Now our TFS is configured correctly, the package are created and published to the nuget server. We can focus on octopus now.
I will not explain how to setup you Octopus environments, machines, ... but only the deployment process I use.
Here is the steps:
- Start Deployment: A notification email to the different member of the project with the details of the packages who will be deployed.
- Clean Environment: A cleanup of the files before the deployment to be sure that if we have remove a file it will not be on the project anymore. This is a powershell script with the following content:
#RootFolder : the root folder of the project (we should be able to get it from the environment) $rootFolder = "E:\Websites\XXX\Website" function Remove-Item-If-Exist { param ( [string]$pathToDelete, [switch]$force, [switch]$recurse ) If (Test-Path $pathToDelete){ Remove-Item $pathToDelete -Force:$force -Recurse:$recurse } } #Cleanup the old files Remove-Item-If-Exist "$rootFolder\Design" -Force -Recurse Remove-Item-If-Exist "$rootFolder\layouts\Layouts" -Force -Recurse Remove-Item-If-Exist "$rootFolder\layouts\Sublayouts" -Force -Recurse Remove-Item-If-Exist "$rootFolder\layouts\UserControls" -Force -Recurse Remove-Item-If-Exist "$rootFolder\bin\PROJECTNAMESPACE.*.dll" -Force Remove-Item-If-Exist "$rootFolder\App_Config\Include\PROJECTNAMESPACE.*.config" -Force
- Deploy Files: Deploy the NuGet package. You may have multiple time this step if you have multiple nuget package with the website files to deploy.
- Deploy TDS: Deploy the NuGet package with the TDS files in a temporary folder.
- Install TDS Packages: This is a powershell to install and publish the TDS packages. I have create a custom tool for it who scan the files in a specific folder and install the packages. If you need to do this kind of program you should take a look at the code of TDS. Basically it install a webservice into your deploy folder, use this webservice to install your packages and then remove this webservice.
A great alternative could be this tool: https://github.com/adoprog/Sitecore-Deployment-Helpers
To do that:
- Add a new file with the extention .ps1 somewhere in your sources and chech-in this file in TFS
- Edit your TFS build definition
- In the tab "Process", section 2.5
- In the section "Post-build script path", select your .ps1 file
- The parameter "Post-build script arguments" I have "-releaseVersion 1.1.J.B" please refer to the post "Step 4: Align the versions numbers" for this.
- The content of the powershell file is the following:
param ( [string]$releaseVersion ) #Constants $octopusApiUrl = "http://10.0.2.50:8088/api" $octopusApiKey = "API-RX6UIIWTB2ZBUWU0TRIYXXXXXXX" $projectName = "XXX" $scriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition #Functions # Get the formated TFS version number. Replace the tokens J and B by the current build number function Format-TFS-Version { param ( [string]$versionToFormat ) $buildNumber = $env:TF_BUILD_BUILDNUMBER Write-Host "env:TF_BUILD_BUILDNUMBER: $buildNumber" if ($buildNumber -eq $null) { $buildIncrementalNumber = 0 } else { $splitted = $buildNumber.Split('.') $buildIncrementalNumber = $splitted[$splitted.Length - 1] } $jdate = Get-Date -format 1MMdd return $versionToFormat.Replace("J", $jdate).Replace("B", $buildIncrementalNumber) } #Create a release in Octopus with the specifiic version of the nuget packages function Octopus-Create-Release { param ( [string]$releaseVersion ) $releaseVersion = Format-TFS-Version $releaseVersion $corePackage = "--package=XXX.Core:$releaseVersion" $corporatePackage = "--package=XXX.Corporate:$releaseVersion" $scriptPackage = "--package=XXX.Tools.SqlScriptsUpdate:$releaseVersion" Write-Host "Create the octopus release by calling $scriptRoot\Octopus\octo.exe create-release --project=$projectName --server=$octopusApiUrl --apiKey=$octopusApiKey --version $releaseVersion $corePackage $corporatePackage $scriptPackage" &$scriptRoot\Octopus\octo.exe create-release --project=$projectName --server=$octopusApiUrl --apiKey=$octopusApiKey --version $releaseVersion $corePackage $corporatePackage $scriptPackage } #Deploy a release in Octopus function Octopus-Deploy-Release { param ( [string]$releaseVersion, [string]$deployToEnvironment ) Write-Host "Deploy the octopus release by calling $scriptRoot\Octopus\octo.exe deploy-release --project=$projectName --version=$releaseVersion --deployto=$deployToEnvironment --server=$octopusApiUrl --apiKey=$octopusApiKey" &$scriptRoot\Octopus\octo.exe deploy-release --project=$projectName --version=$releaseVersion --deployto=$deployToEnvironment --server=$octopusApiUrl --apiKey=$octopusApiKey } #Main program $releaseVersion = Format-TFS-Version $releaseVersion Write-Host "Release version: $releaseVersion" Octopus-Create-Release $releaseVersion Octopus-Deploy-Release $releaseVersion Integration
Ok now your process should be completed. The last post is optional but allow you to have a single ID during the whole build process.
Next steps:
- Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Architecture
- Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Step 1: Customize the TFS workflow
- Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Step 2: Configure TFS
- Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Step 3: Configure octopus
- Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Step 4: Align the version number
No comments:
Post a Comment