Commit bb655368 authored by Viet Hoang's avatar Viet Hoang
Browse files

auto-deploy for simple development framework version 1.9

parent 231ca476
$solutionDir = "%system.teamcity.build.workingDir%".replace('\', '\\');
$instanceRoot = "%vhs.instanceRoot_CM%".replace('\', '\\');
if (Test-Path "%vhs.source.folder%\gulp-config.js")
{
remove-Item %vhs.source.folder%\gulp-config.js
}
$content = 'module.exports = function () {{
var instanceRoot = "{0}";
var config = {{
solutionDir: "{1}",
websiteRoot: instanceRoot + "\\Website",
sitecoreConfigs: instanceRoot + "\\Website",
solutionName: "VietHoang.Sitecore",
buildConfiguration: "%vhs.configuration%",
runCleanBuilds: true,
buildErrorOnFail: %vhs.buildErrorOnFail%,
buildMaxCpuCount: 0,
buildToolsVersion: %vhs.buildToolsVersion%,
MSDeployConf: {{
MSDeployPublishMethod: "RemoteAgent",
DeployIisAppPath: "%vhs.deployIisAppPath_CM%",
MSDeployServiceURL: "%vhs.msDeployServiceUrl_CM%",
UserName: "%vhs.msDeployUsername%",
Password: "%vhs.msDeployPassword%",
RetryAttemptsForDeployment: 5
}},
isCD: false,
forceToPublishWithMsBuild: %vhs.forceToPublishWithMsBuild%,
lastSuccessfulBuildDateTime: "01/01/0001 09:10:55"
}}
return config;
}}' -f $instanceRoot, $solutionDir
new-item -path %vhs.source.folder%\ -name gulp-config.js -type "file" -value $content
Get-Content %vhs.source.folder%\gulp-config.js
\ No newline at end of file
$gulpConfigPath = ".\gulp-config.js"
(Get-Content $gulpConfigPath).replace('%vhs.deployIisAppPath_CM%', '%vhs.deployIisAppPath_CD1%') | Set-Content $gulpConfigPath
(Get-Content $gulpConfigPath).replace('MSDeployServiceURL: "%vhs.msDeployServiceUrl_CM%"', 'MSDeployServiceURL: "%vhs.msDeployServiceUrl_CD1%"') | Set-Content $gulpConfigPath
(Get-Content $gulpConfigPath).replace('isCD: false', 'isCD: true') | Set-Content $gulpConfigPath
Get-Content $gulpConfigPath
\ No newline at end of file
$gulpConfigPath = ".\gulp-config.js"
(Get-Content $gulpConfigPath).replace('%vhs.deployIisAppPath_CD1%', '%vhs.deployIisAppPath_CD2%') | Set-Content $gulpConfigPath
(Get-Content $gulpConfigPath).replace('MSDeployServiceURL: "%vhs.msDeployServiceUrl_CD1%"', 'MSDeployServiceURL: "%vhs.msDeployServiceUrl_CD2%"') | Set-Content $gulpConfigPath
(Get-Content $gulpConfigPath).replace('isCD: false', 'isCD: true') | Set-Content $gulpConfigPath
Get-Content $gulpConfigPath
\ No newline at end of file
$WakeUp = {
Param ([string] $url)
try
{
Write-Output "Waking up $url ..."
$client = new-object system.net.WebClient
$client.UseDefaultCredentials = $true
$null = $client.OpenRead($url)
$client.Dispose()
Write-Output "$url Ok"
} catch {
Write-Error $_
throw $_
}
}
$jobs = @()
# Run your code that needs to be elevated here
@(
"http://%vhs.deployIisAppPath_CM%/",
"http://%vhs.deployIisAppPath_CD1%/",
"http://%vhs.deployIisAppPath_CD2%/"
) | % {
$jobs += Start-Job -ScriptBlock $WakeUp -ArgumentList $_
}
Receive-Job -Job $jobs -Keep
Wait-Job -Job $jobs
\ No newline at end of file
if (Test-Path .\src\Foundation\VietHoang.Serialization\App_Config\Include\z.VietHoang.SerializationSettings.config)
{
remove-Item .\src\Foundation\VietHoang.Serialization\App_Config\Include\z.VietHoang.SerializationSettings.config
}
$content = '<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<sc.variable name="VietHoangSourceFolder" value="{0}" />
<settings>
<!-- Rainbow - SERIALIZATION FOLDER PATH MAX LENGTH
In Windows, there is 248 characters limit on the lenght of file system paths. To avoid exceeding the maximum path length, Rainbow will loop
long paths back to the root. This setting specifies the maximum length of the path to the serialization root path,
which determines how long item paths can be before they are looped.
Important: The value of this setting must be the same on all Sitecore instances accessing the serialized data.
Important: When changing this value, you must reserialize all configurations!
Example: A value of "90" for this setting will mean that item paths longer than 150 characters will be shortened, since Sitecore
reserves 8 characters (and 248 - 8 - 90 = 150).
Default value: 90
-->
<setting name="Rainbow.SFS.SerializationFolderPathMaxLength" value="150" />
<setting name="Rainbow.SFS.MaxItemNameLengthBeforeTruncation" value="50" />
</settings>
</sitecore>
</configuration>
' -f "%vhs.unicorn.sourceFolder%"
new-item -path .\src\Foundation\VietHoang.Serialization\App_Config\Include\ -name z.VietHoang.SerializationSettings.config -type "file" -value $content
Get-Content .\src\Foundation\VietHoang.Serialization\App_Config\Include\z.VietHoang.SerializationSettings.config
\ No newline at end of file
if (Test-Path "%vhs.source.folder%\publishsettings.targets")
{
remove-Item %vhs.source.folder%\publishsettings.targets
}
$content = '<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<publishUrl>http://%vhs.deployIisAppPath_CM%</publishUrl>
</PropertyGroup>
</Project>'
new-item -path %vhs.source.folder%\ -name publishsettings.targets -type "file" -value $content
Get-Content %vhs.source.folder%\publishsettings.targets
\ No newline at end of file
$targetPath = "%vhs.unicorn.sourceFolder%\seria"
$sourcePath = "%system.teamcity.build.checkoutDir%\seria"
$FoldersExclude = '"code" "roles" "Tests"'
$FilesExclude = ""
# /e: Copies subdirectories. Note that this option includes empty directories
# With the /e plus /purge options, if the destination directory exists, the destination directory security settings are not overwritten.
# /xd Excludes directories that match the specified names and paths.
# /xf Excludes files that match the specified names or paths. Note that FileName can include wildcard characters (* and ?).
robocopy $sourcePath $targetPath /e /purge /xd $FoldersExclude /xf $FilesExclude
\ No newline at end of file
if (Test-Path %vhs.source.folder%\GlobalAssemblyInfo.cs)
{
remove-Item %vhs.source.folder%\GlobalAssemblyInfo.cs
}
$content = '
using System.Reflection;
[assembly: AssemblyCompany("VietHoang")]
[assembly: AssemblyCopyright("Copyright VietHoang 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("{0}")]
[assembly: AssemblyInformationalVersion("{0}")]
[assembly: AssemblyFileVersion("{0}")]
' -f "%vhs.AssemblyVersion%"
new-item -path %vhs.source.folder%\ -name GlobalAssemblyInfo.cs -type "file" -value $content
Get-Content %vhs.source.folder%\GlobalAssemblyInfo.cs
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment