Compare commits
11 Commits
master
...
production
Author | SHA1 | Date | |
---|---|---|---|
|
c329524c32 | ||
|
65af9d0a9f | ||
|
0e0a609eda | ||
|
6cd83ba19e | ||
|
f9af97f86c | ||
|
a08dda2dbd | ||
|
94fcfeae26 | ||
|
3baaf63f54 | ||
|
588ed2d522 | ||
|
84966ec75c | ||
|
b17d6b10ea |
129
.jenkins/Jenkinsfile
vendored
Normal file
129
.jenkins/Jenkinsfile
vendored
Normal 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')]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
|
||||
%SystemRoot%\Microsoft.NET\Framework\v3.5\MSBuild.exe publish.proj /t:PrecompileWeb
|
||||
pause
|
Loading…
Reference in New Issue
Block a user