Commit 38eca2a8 authored by Viet Hoang's avatar Viet Hoang
Browse files

add build steps script

parents
if (Test-Path .\GlobalAssemblyInfo.cs)
{
remove-Item .\GlobalAssemblyInfo.cs
}
$content = '
using System.Reflection;
[assembly: AssemblyCompany("Viet Hoang")]
[assembly: AssemblyCopyright("Copyright Viet Hoang 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("{0}")]
[assembly: AssemblyInformationalVersion("{0}")]
[assembly: AssemblyFileVersion("{0}")]
' -f "%vh.AssemblyVersion%"
new-item -path .\ -name GlobalAssemblyInfo.cs -type "file" -value $content
Get-Content .\GlobalAssemblyInfo.cs
\ No newline at end of file
$lastSuccessfulBuildDateTime = "%vh.minDateTimeForCheckingProjectUpdate%"
if (Test-Path "%vh.LastSuccessfulBuildDateTimeFilePath%")
{
$lastSuccessfulBuildDateTime = Get-Content %vh.LastSuccessfulBuildDateTimeFilePath%
}
if (Test-Path ".\gulp-config.js")
{
remove-Item .\gulp-config.js
}
$content = 'module.exports = function () {{
var instanceRoot = "%vh.instanceRoot_CA%";
var config = {{
websiteRoot: instanceRoot + "\\Website",
sitecoreLibraries: instanceRoot + "\\bin",
licensePath: instanceRoot + "\\Data\\license.xml",
solutionName: "VietHoang.Sitecore",
buildConfiguration: "%vh.buildConfiguration%",
runCleanBuilds: true,
errorOnFail: %vh.errorOnFail%,
MSDeployConf: {{
MSDeployPublishMethod: "%vh.deployPublishMethod%",
DeployIisAppPath: "%vh.deployIisAppPath_CA%",
MSDeployServiceURL: "%vh.deployServiceUrl_CA%",
UserName: "%vh.deployUserName%",
Password: "%vh.deployPassword%",
RetryAttemptsForDeployment: 5
}},
lastSuccessfulBuildDateTime: "{0}",
isCD: false
}}
return config;
}}' -f $lastSuccessfulBuildDateTime
new-item -path .\ -name gulp-config.js -type "file" -value $content
Get-Content .\gulp-config.js
\ No newline at end of file
if (Test-Path ".\publishsettings.targets")
{
remove-Item .\publishsettings.targets
}
$content = '<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<publishUrl>%vh.deployServiceUrl_CA%</publishUrl>
</PropertyGroup>
</Project>'
new-item -path .\ -name publishsettings.targets -type "file" -value $content
Get-Content .\publishsettings.targets
\ 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="sourceFolder" 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 "%vh.unicornFolder%"
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
$targetPath = "%vh.unicornFolder%\serialization"
$sourcePath = "%system.teamcity.build.checkoutDir%\serialization"
$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 "%vh.LastSuccessfulBuildDateTimeFilePath%")
{
remove-Item %vh.LastSuccessfulBuildDateTimeFilePath%
}
$content = $([DateTime]::Now)
new-item %vh.LastSuccessfulBuildDateTimeFilePath% -type "file" -value $content
Get-Content %vh.LastSuccessfulBuildDateTimeFilePath%
\ No newline at end of file
$gulpConfigPath = ".\gulp-config.js"
(Get-Content $gulpConfigPath).replace('%vh.instanceRoot_CA%', '%vh.instanceRoot_CD1%') | Set-Content $gulpConfigPath
(Get-Content $gulpConfigPath).replace('DeployIisAppPath: "%vh.deployIisAppPath_CA%"', 'DeployIisAppPath: "%vh.deployIisAppPath_CD1%"') | Set-Content $gulpConfigPath
(Get-Content $gulpConfigPath).replace('MSDeployServiceURL: "%vh.deployServiceUrl_CA%"', 'MSDeployServiceURL: "%vh.deployServiceUrl_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('%vh.instanceRoot_CD1%', '%vh.instanceRoot_CD2%') | Set-Content $gulpConfigPath
(Get-Content $gulpConfigPath).replace('DeployIisAppPath: "%vh.deployIisAppPath_CD1%"', 'DeployIisAppPath: "%vh.deployIisAppPath_CD2%"') | Set-Content $gulpConfigPath
(Get-Content $gulpConfigPath).replace('MSDeployServiceURL: "%vh.deployServiceUrl_CD1%"', 'MSDeployServiceURL: "%vh.deployServiceUrl_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://viethoang.cd1.local",
"http://viethoang.cd2.local"
) | % {
$jobs += Start-Job -ScriptBlock $WakeUp -ArgumentList $_
}
Receive-Job -Job $jobs -Keep
Wait-Job -Job $jobs
\ 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