Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 42 additions & 12 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ pipeline {
agent {
label 'docker'
}

parameters {
booleanParam(name: 'DEPLOY_STAGING', defaultValue: true, description: 'Deploy to index.staging.scheme.org')
booleanParam(name: 'DEPLOY_PROD', defaultValue: false, description: 'Deploy to index.scheme.org')
}

stages {

Expand All @@ -15,7 +20,7 @@ pipeline {
stage('Build') {
agent {
docker {
image 'docker:cli'
image 'docker:20.10.24-cli'
args "-u root"
reuseNode true
}
Expand All @@ -30,25 +35,50 @@ pipeline {
}
}

stage('Deploy') {
stage('Deploy staging') {
agent {
dockerfile {
filename './deploy/rsync.Dockerfile'
reuseNode true
}
}
when {
expression {
return params.DEPLOY_STAGING
}
}
steps {
sshagent(credentials: ['index_staging_tuonela_ssh']) {
sh '''
mkdir ~/.ssh
ssh-keyscan -t rsa tuonela.scheme.org >> ~/.ssh/known_hosts
rsync schemeindex.zip stag-index@tuonela.scheme.org:/staging/index/update/schemeindex.zip
ssh stag-index@tuonela.scheme.org 'cd ~ ; bash install-update.sh'
'''
}
}
}

stage('Deploy production') {
agent {
dockerfile {
filename './deploy/ansible.Dockerfile'
filename './deploy/rsync.Dockerfile'
reuseNode true
}
}
when {
branch 'master'
expression {
return params.DEPLOY_PROD
}
}
steps {
dir('deploy') {
sh 'pip install ansible'
sshagent(credentials: ['index_scheme_org_ssh']) {
sh '''
ssh-keyscan -t rsa index.scheme.org >> ~/.ssh/known_hosts
ansible-playbook -i hosts deploy.yml -e content_zip_file=../schemeindex.zip
'''
}
sshagent(credentials: ['index_tuonela_ssh']) {
sh '''
mkdir ~/.ssh
ssh-keyscan -t rsa tuonela.scheme.org >> ~/.ssh/known_hosts
rsync schemeindex.zip prod-index@tuonela.scheme.org:/production/index/update/schemeindex.zip
ssh prod-index@tuonela.scheme.org 'cd ~ ; bash install-update.sh'
'''
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions deploy/README.adoc

This file was deleted.

6 changes: 0 additions & 6 deletions deploy/ansible.Dockerfile

This file was deleted.

21 changes: 0 additions & 21 deletions deploy/deploy.yml

This file was deleted.

7 changes: 0 additions & 7 deletions deploy/hosts

This file was deleted.

2 changes: 2 additions & 0 deletions deploy/rsync.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM ubuntu:24.04
RUN apt-get update && apt-get install -y ssh rsync
26 changes: 0 additions & 26 deletions deploy/template/scheme_index.conf

This file was deleted.

Loading