2021-12-06 12:08:50 +00:00
|
|
|
println("Job name: ${JOB_NAME}")
|
|
|
|
|
|
|
|
switch(JOB_NAME) {
|
2021-12-06 14:43:41 +00:00
|
|
|
case "production.helpcenter.onlyoffice.com.pl":
|
2021-12-06 12:08:50 +00:00
|
|
|
DESTSITE = 'helpcenter.teamlab.com'
|
|
|
|
DESTHOST = '54.186.188.62'
|
|
|
|
MONITOR_ID = '58439000008116012'
|
2021-12-06 14:43:41 +00:00
|
|
|
break
|
|
|
|
case "release.test-helpcenter.onlyoffice.pl":
|
2021-12-06 12:08:50 +00:00
|
|
|
DESTSITE = 'test-helpcenter.teamlab.com'
|
|
|
|
DESTHOST = '54.186.188.62'
|
2021-12-06 14:43:41 +00:00
|
|
|
break
|
|
|
|
default:
|
|
|
|
println("JOB: ${JOB_NAME} not known.")
|
|
|
|
System.exit(1)
|
2021-12-06 12:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
println("SITE: ${DESTSITE}")
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent { label 'master' }
|
|
|
|
options {
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
buildDiscarder (logRotator(numToKeepStr: '5', artifactNumToKeepStr: '5'))
|
|
|
|
}
|
|
|
|
parameters {
|
|
|
|
choice(name: 'DEPLOY', choices: ['False','True'],description: 'Run deploy? Set "True" to run, "False" to update job')
|
|
|
|
}
|
|
|
|
stages {
|
2021-12-06 14:43:41 +00:00
|
|
|
stage('build') {
|
2021-12-06 12:08:50 +00:00
|
|
|
when { expression { return env.DEPLOY == "True" } }
|
2021-12-06 14:43:41 +00:00
|
|
|
environment {
|
|
|
|
DESTSITE = "${DESTSITE}"
|
|
|
|
DESTHOST = "${DESTHOST}"
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
withCredentials([usernamePassword(credentialsId: 'jenkins_user_api',
|
2021-12-06 12:08:50 +00:00
|
|
|
passwordVariable: 'jenkins_token',
|
|
|
|
usernameVariable: 'jenkins_user')])
|
2021-12-06 14:43:41 +00:00
|
|
|
{
|
2021-12-06 12:08:50 +00:00
|
|
|
powershell '''
|
|
|
|
$ErrorActionPreference='Stop'
|
|
|
|
(get-content Web\\web.config) | %{$_ -replace '<rule name="pages HTTP to HTTPS" enabled="false" stopProcessing="true">', '<rule name="pages HTTP to HTTPS" enabled="true" stopProcessing="true">'} | set-content Web\\web.config
|
|
|
|
(get-content sync.bat) | %{$_ -replace "%poolname%", "$Env:DESTSITE"} | set-content sync.bat
|
|
|
|
if ( $Env:JOB_NAME -eq "production.helpcenter.onlyoffice.com.pl") {
|
|
|
|
(get-content publish.proj) | %{$_ -replace 'Updateable="true"', 'Updateable="false"'} | set-content publish.proj
|
|
|
|
}
|
2023-11-29 13:09:36 +00:00
|
|
|
if ( $Env:JOB_NAME -eq "production.helpcenter.onlyoffice.com.pl") {
|
|
|
|
(Get-Content "Web\\web.config" -Raw) -replace '(?ms)<rule name="redirect-test-helpcenternew-[^>]+>.*?</rule>\r?\n*', '' | Set-Content "Web\\web.config"
|
|
|
|
}
|
2021-12-06 12:08:50 +00:00
|
|
|
'''
|
|
|
|
bat '''
|
|
|
|
echo " == Build == "
|
|
|
|
%msbuild% %WORKSPACE%\\publish.proj /t:PrecompileWeb
|
|
|
|
|
2021-12-06 13:00:08 +00:00
|
|
|
if not %errorlevel% == 0 (
|
|
|
|
echo "Error: cannot deploy the project"
|
|
|
|
exit -1
|
|
|
|
)
|
|
|
|
|
2021-12-06 12:08:50 +00:00
|
|
|
echo "Add changelog.xml for check build information"
|
|
|
|
curl -k -s -u %jenkins_user%:%jenkins_token% "%BUILD_URL%api/xml" > %WORKSPACE%\\Precompiled\\changelog.xml
|
|
|
|
|
|
|
|
echo " == Precompile == "
|
|
|
|
%aspnetmerge% "%WORKSPACE%\\Precompiled" -w ASC.dll
|
|
|
|
'''
|
2021-12-06 14:43:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-06 12:08:50 +00:00
|
|
|
|
2021-12-06 14:43:41 +00:00
|
|
|
stage('stop_monitor') {
|
2021-12-06 12:08:50 +00:00
|
|
|
when {
|
|
|
|
allOf { expression { return env.DEPLOY == "True" }; expression { return env.JOB_NAME == 'production.helpcenter.onlyoffice.com.pl' } }
|
|
|
|
}
|
2021-12-06 14:43:41 +00:00
|
|
|
steps {
|
|
|
|
build job: 'monitor.24x7.start.stop',
|
|
|
|
parameters: [string(name: 'monitor_id', value: "${MONITOR_ID}"),
|
|
|
|
string(name: 'action', value: 'suspend')]
|
|
|
|
}
|
|
|
|
}
|
2021-12-06 12:08:50 +00:00
|
|
|
|
2021-12-06 14:43:41 +00:00
|
|
|
stage('deploy') {
|
2021-12-06 12:08:50 +00:00
|
|
|
when { expression { return env.DEPLOY == "True" } }
|
2021-12-06 14:43:41 +00:00
|
|
|
environment {
|
|
|
|
DESTSITE = "${DESTSITE}"
|
|
|
|
DESTHOST = "${DESTHOST}"
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
withCredentials([usernamePassword(credentialsId: 'sites.onlyoffice.com_21H1',
|
2021-12-06 12:08:50 +00:00
|
|
|
passwordVariable: 'deploymentpass',
|
|
|
|
usernameVariable: 'deploymentuser')])
|
2021-12-06 14:43:41 +00:00
|
|
|
{
|
2021-12-06 12:08:50 +00:00
|
|
|
bat '''
|
|
|
|
echo " == Deploy == "
|
|
|
|
%msdeployv2% -verb:sync -source:iisapp="%WORKSPACE%\\Precompiled" -dest:iisapp="%DESTSITE%",computerName="%DESTHOST%",username=%deploymentuser%,password=%deploymentpass% -preSync:runCommand="%WORKSPACE%\\sync.bat",waitInterval=120000 -postSync:runCommand="%WORKSPACE%\\sync.bat",waitInterval=120000
|
|
|
|
'''
|
2021-12-06 14:43:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-06 12:08:50 +00:00
|
|
|
|
|
|
|
stage('notify telegram') {
|
|
|
|
when {
|
|
|
|
allOf { expression { return env.DEPLOY == "True" }; expression { return env.JOB_NAME == 'production.helpcenter.onlyoffice.com.pl' } }
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
withCredentials([string(credentialsId: 'chat_dep_automation_operation', variable: 'TEL_CHAT'),
|
|
|
|
string(credentialsId: 'token_bot_jenkins_notifier', variable: 'TEL_TOKEN')])
|
2021-12-06 14:43:41 +00:00
|
|
|
{
|
2021-12-06 12:08:50 +00:00
|
|
|
powershell '''
|
|
|
|
$MESSAGE = "helpcenter.onlyoffice.com is deployed."
|
|
|
|
$TOKEN = "$Env:TEL_TOKEN"
|
|
|
|
$CHAT_ID = "$Env:TEL_CHAT"
|
|
|
|
$URL = "https://api.telegram.org/bot$TOKEN/sendMessage"
|
|
|
|
if ( $Env:BRANCH_NAME -eq "production_deploy") {
|
|
|
|
Invoke-WebRequest -Uri $URL -Body @{chat_id=$CHAT_ID; text=$MESSAGE} -UseBasicParsing
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-06 14:43:41 +00:00
|
|
|
stage('start_monitor') {
|
2021-12-06 12:08:50 +00:00
|
|
|
when {
|
|
|
|
allOf { expression { return env.DEPLOY == "True" }; expression { return env.JOB_NAME == 'production.helpcenter.onlyoffice.com.pl' } }
|
|
|
|
}
|
2021-12-06 14:43:41 +00:00
|
|
|
steps {
|
2021-12-06 12:08:50 +00:00
|
|
|
powershell '''
|
|
|
|
[int]$statusCode = 0
|
|
|
|
|
|
|
|
for ($i=30; $i -gt 0; $i--)
|
|
|
|
{
|
2021-12-06 14:45:51 +00:00
|
|
|
$statusCode = (cmd.exe /c "curl --connect-timeout 2 -L -s -o NUL -w %{http_code} https://helpcenter.onlyoffice.com/") | Out-String
|
2021-12-06 12:08:50 +00:00
|
|
|
|
2021-12-06 14:45:51 +00:00
|
|
|
if ( $statusCode -eq 200 )
|
|
|
|
{
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Write-Host "helpcenter.onlyoffice.com not available"
|
|
|
|
Start-Sleep -s 60
|
|
|
|
}
|
2021-12-06 12:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Write-Host "helpcenter.onlyoffice.com do not available after deploy within 30 minutes"
|
2021-12-06 14:43:41 +00:00
|
|
|
'''
|
2021-12-06 12:08:50 +00:00
|
|
|
|
|
|
|
build job: 'monitor.24x7.start.stop',
|
|
|
|
parameters: [string(name: 'monitor_id', value: "${MONITOR_ID}"),
|
|
|
|
string(name: 'action', value: 'activate')]
|
2021-12-06 14:43:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-06 12:08:50 +00:00
|
|
|
}
|