Create Jenkinsfile

This commit is contained in:
AlexandrKharitonov 2021-05-26 15:56:21 +03:00
parent a2ba8939b8
commit b17d6b10ea

62
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,62 @@
pipeline {
agent { label 'master' }
triggers {
githubPush()
}
options {
disableConcurrentBuilds()
buildDiscarder (logRotator(numToKeepStr: '3', artifactNumToKeepStr: '3'))
}
stages {
stage('test_deploy') {
when {
branch 'test_deploy'
}
environment {
DESTSITE = 'testdeploy'
DESTHOST = '18.224.174.2'
}
steps {
withCredentials([
usernamePassword(credentialsId: 'deploymentuser_pass', usernameVariable: 'deploymentuser', passwordVariable: 'deploymentpass')
])
{
powershell '''
$ErrorActionPreference='Stop'
(get-content testdeploy\\scripts\\sync.bat) | %{$_ -replace "%poolname%", "$Env:DESTSITE"} | set-content testdeploy\\scripts\\sync.bat
'''
bat '''
echo " == Deploy == "
%msdeployv2% -verb:sync -source:iisapp="%WORKSPACE%\\testdeploy\\Precompiled" -dest:iisapp="%DESTSITE%",computerName="%DESTHOST%",username=%deploymentuser%,password=%deploymentpass% -preSync:runCommand="%WORKSPACE%\\testdeploy\\scripts\\sync.bat",waitInterval=120000 -postSync:runCommand="%WORKSPACE%\\testdeploy\\scripts\\sync.bat",waitInterval=120000
'''
}
}
}
stage('production_deploy') {
when {
branch 'production_deploy'
}
environment {
DESTSITE = 'testproddeploy'
DESTHOST = '18.224.174.2'
}
steps {
withCredentials([
usernamePassword(credentialsId: 'deploymentuser_pass', usernameVariable: 'deploymentuser', passwordVariable: 'deploymentpass')
])
{
powershell '''
$ErrorActionPreference='Stop'
(get-content testdeploy\\scripts\\sync.bat) | %{$_ -replace "%poolname%", "$Env:DESTSITE"} | set-content testdeploy\\scripts\\sync.bat
'''
bat '''
echo " == Deploy == "
%msdeployv2% -verb:sync -source:iisapp="%WORKSPACE%\\testdeploy\\Precompiled" -dest:iisapp="%DESTSITE%",computerName="%DESTHOST%",username=%deploymentuser%,password=%deploymentpass% -preSync:runCommand="%WORKSPACE%\\testdeploy\\scripts\\sync.bat",waitInterval=120000 -postSync:runCommand="%WORKSPACE%\\testdeploy\\scripts\\sync.bat",waitInterval=120000
'''
}
}
}
}
}