Update Jenkinsfile

This commit is contained in:
AlexandrKharitonov 2021-12-06 17:43:41 +03:00
parent 0eed0e7d16
commit 17de3bbf2c

86
.jenkins/Jenkinsfile vendored
View File

@ -1,18 +1,18 @@
println("Job name: ${JOB_NAME}")
switch(JOB_NAME) {
case "production.helpcenter.onlyoffice.com.pl":
case "production.helpcenter.onlyoffice.com.pl":
DESTSITE = 'helpcenter.teamlab.com'
DESTHOST = '54.186.188.62'
MONITOR_ID = '58439000008116012'
break
case "release.test-helpcenter.onlyoffice.pl":
break
case "release.test-helpcenter.onlyoffice.pl":
DESTSITE = 'test-helpcenter.teamlab.com'
DESTHOST = '54.186.188.62'
break
default:
println("JOB: ${JOB_NAME} not known.")
System.exit(1)
break
default:
println("JOB: ${JOB_NAME} not known.")
System.exit(1)
}
println("SITE: ${DESTSITE}")
@ -27,17 +27,17 @@ pipeline {
choice(name: 'DEPLOY', choices: ['False','True'],description: 'Run deploy? Set "True" to run, "False" to update job')
}
stages {
stage('build') {
stage('build') {
when { expression { return env.DEPLOY == "True" } }
environment {
DESTSITE = "${DESTSITE}"
DESTHOST = "${DESTHOST}"
}
steps {
withCredentials([usernamePassword(credentialsId: 'jenkins_user_api',
environment {
DESTSITE = "${DESTSITE}"
DESTHOST = "${DESTHOST}"
}
steps {
withCredentials([usernamePassword(credentialsId: 'jenkins_user_api',
passwordVariable: 'jenkins_token',
usernameVariable: 'jenkins_user')])
{
{
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
@ -61,39 +61,39 @@ pipeline {
echo " == Precompile == "
%aspnetmerge% "%WORKSPACE%\\Precompiled" -w ASC.dll
'''
}
}
}
}
}
}
stage('stop_monitor') {
stage('stop_monitor') {
when {
allOf { expression { return env.DEPLOY == "True" }; expression { return env.JOB_NAME == 'production.helpcenter.onlyoffice.com.pl' } }
}
steps {
build job: 'monitor.24x7.start.stop',
parameters: [string(name: 'monitor_id', value: "${MONITOR_ID}"),
string(name: 'action', value: 'suspend')]
}
}
steps {
build job: 'monitor.24x7.start.stop',
parameters: [string(name: 'monitor_id', value: "${MONITOR_ID}"),
string(name: 'action', value: 'suspend')]
}
}
stage('deploy') {
stage('deploy') {
when { expression { return env.DEPLOY == "True" } }
environment {
DESTSITE = "${DESTSITE}"
DESTHOST = "${DESTHOST}"
}
steps {
withCredentials([usernamePassword(credentialsId: 'sites.onlyoffice.com_21H1',
environment {
DESTSITE = "${DESTSITE}"
DESTHOST = "${DESTHOST}"
}
steps {
withCredentials([usernamePassword(credentialsId: 'sites.onlyoffice.com_21H1',
passwordVariable: 'deploymentpass',
usernameVariable: 'deploymentuser')])
{
{
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
'''
}
}
}
}
}
}
stage('notify telegram') {
when {
@ -102,7 +102,7 @@ pipeline {
steps {
withCredentials([string(credentialsId: 'chat_dep_automation_operation', variable: 'TEL_CHAT'),
string(credentialsId: 'token_bot_jenkins_notifier', variable: 'TEL_TOKEN')])
{
{
powershell '''
$MESSAGE = "helpcenter.onlyoffice.com is deployed."
$TOKEN = "$Env:TEL_TOKEN"
@ -115,11 +115,11 @@ pipeline {
}
}
}
stage('start_monitor') {
stage('start_monitor') {
when {
allOf { expression { return env.DEPLOY == "True" }; expression { return env.JOB_NAME == 'production.helpcenter.onlyoffice.com.pl' } }
}
steps {
steps {
powershell '''
[int]$statusCode = 0
@ -140,12 +140,12 @@ pipeline {
}
Write-Host "helpcenter.onlyoffice.com do not available after deploy within 30 minutes"
'''
'''
build job: 'monitor.24x7.start.stop',
parameters: [string(name: 'monitor_id', value: "${MONITOR_ID}"),
string(name: 'action', value: 'activate')]
}
}
}
}
}
}
}