diff options
Diffstat (limited to 'jjb/pharos')
-rw-r--r-- | jjb/pharos/pharos-rtd-jobs.yaml | 12 | ||||
-rw-r--r-- | jjb/pharos/pharos-tools.yml | 51 | ||||
-rw-r--r-- | jjb/pharos/pharos.yaml | 77 | ||||
-rw-r--r-- | jjb/pharos/shell/backup-dashboard.sh | 28 | ||||
-rw-r--r-- | jjb/pharos/shell/deploy-dashboard.sh | 19 |
5 files changed, 110 insertions, 77 deletions
diff --git a/jjb/pharos/pharos-rtd-jobs.yaml b/jjb/pharos/pharos-rtd-jobs.yaml new file mode 100644 index 000000000..60bcd8a00 --- /dev/null +++ b/jjb/pharos/pharos-rtd-jobs.yaml @@ -0,0 +1,12 @@ +--- +- project: + name: pharos-rtd + project: pharos + project-name: pharos + + project-pattern: 'pharos' + rtd-build-url: 'https://readthedocs.org/api/v2/webhook/opnfv-pharos/47385/' + rtd-token: '12cb789478d0c3577fb62c610232b3113d3a16ad' + + jobs: + - '{project-name}-rtd-jobs' diff --git a/jjb/pharos/pharos-tools.yml b/jjb/pharos/pharos-tools.yml new file mode 100644 index 000000000..ac5d1956e --- /dev/null +++ b/jjb/pharos/pharos-tools.yml @@ -0,0 +1,51 @@ +--- +- project: + name: pharos-dashboard-jobs + + project: 'pharos-tools' + + disabled: false + + jobs: + - '{project}-verify-basic' + - 'pharos-dashboard-backup' + - 'pharos-dashboard-deploy' + +- job-template: + name: 'pharos-dashboard-backup' + + disabled: '{obj:disabled}' + + parameters: + - 'pharos-dashboard-defaults' + + triggers: + - timed: '@daily' + + builders: + - shell: + !include-raw: shell/backup-dashboard.sh + +- job-template: + name: 'pharos-dashboard-deploy' + + disabled: '{obj:disabled}' + + parameters: + - project-parameter: + project: '{project}' + branch: 'master' + - 'pharos-dashboard-defaults' + + scm: + - git-scm-gerrit + + triggers: + - gerrit-trigger-change-merged: + branch: 'master' + project: '{project}' + files: 'dashboard/docker-compose.yml' + + builders: + - shell: + !include-raw: shell/deploy-dashboard.sh diff --git a/jjb/pharos/pharos.yaml b/jjb/pharos/pharos.yaml index c1bb1ba0e..0b5119657 100644 --- a/jjb/pharos/pharos.yaml +++ b/jjb/pharos/pharos.yaml @@ -4,85 +4,8 @@ project: - '{name}' - - '{name}-tools' disabled: false jobs: - '{project}-verify-basic' - - 'backup-pharos-dashboard' - - 'deploy-pharos-dashboard': - disabled: true - -- job-template: - name: 'backup-pharos-dashboard' - - disabled: '{obj:disabled}' - - parameters: - - 'pharos-dashboard-defaults' - - triggers: - - timed: '@daily' - - builders: - - shell: | - BACKUP_DIR=$HOME/backups/ - TMP_DIR=$HOME/tmp/ - mkdir -p $BACKUP_DIR - echo "-- $(date +%Y%m%d) --" - echo "Backing up Pharos Dashboard data..." - sudo docker run --rm \ - -v pharos-data:/pharos-data:ro \ - -v $TMP_DIR:/backup \ - alpine \ - tar -czf /backup/pharos-dashboard-db-$(date +%Y%m%d).tar.gz -C /pharos-data ./ - sudo mv $TMP_DIR/pharos-dashboard-db-$(date +%Y%m%d).tar.gz $BACKUP_DIR - sudo chown $USER:$USER $BACKUP_DIR/pharos-dashboard-db-$(date +%Y%m%d).tar.gz - echo "...complete" - -- job-template: - name: 'deploy-pharos-dashboard' - - disabled: '{obj:disabled}' - - parameters: - - project-parameter: - project: 'pharos-tools' - branch: 'master' - - 'pharos-dashboard-defaults' - - scm: - - git: - choosing-strategy: 'gerrit' - refspec: '$GERRIT_REFSPEC' - branches: - - 'origin/$BRANCH' - timeout: 15 - credentials-id: '$SSH_CREDENTIAL_ID' - url: '$GIT_BASE' - skip-tag: true - wipe-workspace: false - - triggers: - - gerrit: - server-name: 'gerrit.opnfv.org' - trigger-on: - - ref-updated-event - - comment-added-contains-event: - comment-contains-value: '^redeploy$' - projects: - - project-compare-type: 'ANT' - project-pattern: 'pharos-tools' - branches: - - branch-compare-type: 'ANT' - branch-pattern: '**/master' - - builders: - - shell: | - cp $HOME/config.env $WORKSPACE/dashboard - cp $HOME/rsa.pub $WORKSPACE/dashboard - cp $HOME/rsa.pem $WORKSPACE/dashboard - cd $WORKSPACE/dashboard - sudo docker-compose build - sudo docker-compose up -d diff --git a/jjb/pharos/shell/backup-dashboard.sh b/jjb/pharos/shell/backup-dashboard.sh new file mode 100644 index 000000000..4c1c01500 --- /dev/null +++ b/jjb/pharos/shell/backup-dashboard.sh @@ -0,0 +1,28 @@ +#!/bin/bash -eux +############################################################################## +# Copyright (c) 2018 Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +BACKUP_DIR=$HOME/backups +DATE=$(date +%Y%m%d) +TAR_FILE=pharos-dashboard-db-$DATE.tar.tz + +mkdir -p $BACKUP_DIR +echo "-- $DATE --" +echo "--> Backing up Pharos Dashboard" + +docker run --rm \ + -v pharos-data:/pharos-data:ro \ + -v $BACKUP_DIR:/backup \ + alpine \ + tar -czf /backup/$TAR_FILE -C /pharos-data ./ + +/usr/local/bin/gsutil cp $BACKUP_DIR/$TAR_FILE \ + gs://opnfv-backups/pharos-dashboard/ && rm $BACKUP_DIR/$TAR_FILE + +echo "--> Pharos dashboard backup complete" diff --git a/jjb/pharos/shell/deploy-dashboard.sh b/jjb/pharos/shell/deploy-dashboard.sh new file mode 100644 index 000000000..46a79c326 --- /dev/null +++ b/jjb/pharos/shell/deploy-dashboard.sh @@ -0,0 +1,19 @@ +#!/bin/bash -eux +############################################################################## +# Copyright (c) 2018 Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +cp $HOME/config.env $WORKSPACE/dashboard +cd $WORKSPACE/dashboard + +docker-compose pull +docker-compose up -d + +# Copy JIRA keys into web container +WEB_CONTAINER="$(docker ps --filter 'name=dg01' -q)" +docker cp $HOME/rsa.pub $WEB_CONTAINER:/pharos_dashboard/account/ +docker cp $HOME/rsa.pem $WEB_CONTAINER:/pharos_dashboard/account/ |