pipeline {
agent any
environment {
projectKeyFront = 'kvn-yanotes-front'
projectKeyBack = 'kvn-yanotes-back'
VUE_APP_STS_SERVER= 'https://auth.yanotes-dev.loc'
VUE_APP_REDIRECT_BASE = 'https://yanotes-dev.loc'
VUE_APP_CLIENT_NAME = 'yanotes_dev'
}
stages {
stage('build client app') {
agent {
dockerfile {
filename 'Dockerfile-node'
}
}
steps {
sh 'cd ./YANotesServer/App/ && npm install --verbose'
sh 'cd ./YANotesServer/App/ && npm run build'
stash includes: 'YANotesServer/App/**/*', name: 'client-app'
sh 'rm -rf ./YANotesServer/App'
}
}
stage('build server app') {
agent {
dockerfile {
filename 'Dockerfile-dotnet-microsoft6'
}
}
steps {
unstash 'client-app'
sh '''
dotnet publish --framework net6.0 --configuration Release --runtime centos-x64 ./YANotes.sln
'''
stash includes: 'StsServer/bin/Release/net6.0/centos-x64/publish/**/*', name: 'auth'
stash includes: 'YANotesServer/bin/Release/net6.0/centos-x64/publish/**/*', name: 'app'
}
}
stage('install systemd unit file') {
agent any
steps {
sshagent(['jenkins-ci-yanotes-dev']) {
sh 'scp SystemdUnitFiles/yanotes.service-Dev root@yanotes-dev.loc:/etc/systemd/system/yanotes.dev.service'
sh 'scp SystemdUnitFiles/yanotes.auth.service-Dev root@yanotes-dev.loc:/etc/systemd/system/yanotes.auth.dev.service'
sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc systemctl daemon-reload'
sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc systemctl enable yanotes.dev'
sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc systemctl enable yanotes.auth.dev'
}
}
}
stage('deployment web application') {
agent any
steps {
sshagent(['jenkins-ci-yanotes-dev']) {
unstash 'app'
sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc systemctl stop yanotes.dev'
// sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc rm -rf /var/yanotes'
sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc mkdir -p /var/yanotes'
sh 'scp -r ./YANotesServer/bin/Release/net6.0/centos-x64/publish/* root@yanotes-dev.loc:/var/yanotes'
sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc systemctl start yanotes.dev'
}
}
}
stage('deployment auth application') {
agent any
steps {
sshagent(['jenkins-ci-yanotes-dev']) {
unstash 'auth'
sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc systemctl stop yanotes.auth.dev'
// sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc rm -rf /var/yanotesauth'
sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc mkdir -p /var/yanotesauth'
sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc mkdir -p /var/yanotesauth/logs'
sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc chmod 777 /var/yanotesauth/logs'
sh 'scp -r ./StsServer/bin/Release/net6.0/centos-x64/publish/* root@yanotes-dev.loc:/var/yanotesauth'
sh 'ssh -o StrictHostKeyChecking=no root@yanotes-dev.loc systemctl start yanotes.auth.dev'
}
}
}
}
}
dotnet publish -c Release -r linux-x64 --self-contained true /p:PublishReadyToRun=true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true