Compare commits

...

11 Commits

Author SHA1 Message Date
AlexandrKharitonov
c329524c32 Update Jenkinsfile 2021-06-04 14:23:16 +03:00
AlexandrKharitonov
65af9d0a9f Update Jenkinsfile 2021-06-04 13:47:58 +03:00
AlexandrKharitonov
0e0a609eda create .jenkins folder 2021-06-04 13:24:07 +03:00
AlexandrKharitonov
6cd83ba19e Update Jenkinsfile 2021-06-02 09:53:57 +03:00
AlexandrKharitonov
f9af97f86c Update Jenkinsfile 2021-05-31 10:37:51 +03:00
AlexandrKharitonov
a08dda2dbd Update Jenkinsfile 2021-05-31 10:37:06 +03:00
AlexandrKharitonov
94fcfeae26 Update Jenkinsfile 2021-05-27 09:34:16 +03:00
AlexandrKharitonov
3baaf63f54 Update Jenkinsfile 2021-05-26 18:26:17 +03:00
AlexandrKharitonov
588ed2d522 Update Jenkinsfile 2021-05-26 16:32:22 +03:00
AlexandrKharitonov
84966ec75c Update Jenkinsfile 2021-05-26 15:58:50 +03:00
AlexandrKharitonov
b17d6b10ea Create Jenkinsfile 2021-05-26 15:56:21 +03:00
2 changed files with 129 additions and 3 deletions

129
.jenkins/Jenkinsfile vendored Normal file
View File

@ -0,0 +1,129 @@
if ("${BRANCH_NAME}" == 'test_deploy') {
DESTSITE = 'test-helpcenter.teamlab.com'
DESTHOST = '54.186.188.62'
LETTER = 'I:'
}
if ("${BRANCH_NAME}" == 'production_deploy') {
DESTSITE = 'testproddeploy'
DESTHOST = '18.224.174.2'
LETTER = 'U:'
}
pipeline {
agent { label 'master' }
triggers {
githubPush()
}
options {
disableConcurrentBuilds()
buildDiscarder (logRotator(numToKeepStr: '3', artifactNumToKeepStr: '3'))
}
stages {
stage('stop_monitor') {
when {
branch 'production_deploy'
}
steps {
build job: 'monitor.24x7.start.stop', \
parameters: [string(name: 'monitor_id', value: '58439000004453003'), \
string(name: 'action', value: 'suspend')]
}
}
stage('deploy') {
when {
anyOf { branch 'test_deploy'; branch 'production_deploy' }
}
environment {
DESTSITE = "${DESTSITE}"
DESTHOST = "${DESTHOST}"
LETTER = "${LETTER}"
}
steps {
withCredentials([
usernamePassword(credentialsId: 'deploymentuser_pass', usernameVariable: 'deploymentuser', passwordVariable: 'deploymentpass'),
string(credentialsId: 'chat_dep_automation_operation', variable: 'TEL_CHAT'),
string(credentialsId: 'token_bot_jenkins_notifier', variable: 'TEL_TOKEN')
])
{
bat '''
if not exist %LETTER% subst %LETTER% %WORKSPACE%
'''
powershell '''
$ErrorActionPreference='Stop'
(get-content sync.bat) | %{$_ -replace "%poolname%", "$Env:DESTSITE"} | set-content sync.bat
if ( $Env:BRANCH_NAME -eq "production_deploy") {
(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
}
'''
bat '''
echo " == Build == "
%msbuild% %LETTER%\\publish.proj /t:PrecompileWeb
'''
bat '''
echo " == Deploy == "
%msdeployv2% -verb:sync -source:iisapp="%LETTER%\\Precompiled" -dest:iisapp="%DESTSITE%",computerName="%DESTHOST%",username=%deploymentuser%,password=%deploymentpass% -preSync:runCommand="%LETTER%\\sync.bat",waitInterval=120000 -postSync:runCommand="%LETTER%\\sync.bat",waitInterval=120000
'''
bat 'subst %LETTER% /D'
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
}
'''
}
}
}
stage('start_monitor') {
when {
branch 'production_deploy'
}
steps {
script {
def remote = [:]
remote.name = "ubuntu"
remote.host = "52.12.249.74"
remote.allowAnyHosts = true
withCredentials([
sshUserPrivateKey(credentialsId: 'bb5bee01-660a-4016-a6bb-68f06b1cc827', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'UName')
])
{
remote.user = UName
remote.identityFile = identity
sshCommand remote: remote, command: '''
check_site_status () {
if curl -s --head --request GET https://helpcenter.onlyoffice.com | grep "200 OK" > /dev/null; then
echo `date`
return 0
else
return 1
fi
}
# check i=30 minuts
for ((i=30; i>0 ; i--))
do
if check_site_status; then
exit 0
else
sleep 60
fi
done
echo "helpcenter.onlyoffice.com do not available after deploy within 30 minutes"
'''
}
}
build job: 'monitor.24x7.start.stop', \
parameters: [string(name: 'monitor_id', value: '58439000004453003'), \
string(name: 'action', value: 'activate')]
}
}
}
}

View File

@ -1,3 +0,0 @@
%SystemRoot%\Microsoft.NET\Framework\v3.5\MSBuild.exe publish.proj /t:PrecompileWeb
pause