From 13c1b1292be5c27238622cbca55577af7939f9be Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 13:54:37 +0200 Subject: [PATCH 01/13] Added doc deployment --- Dockerfile | 9 ++++++++ Jenkinsfile | 64 ++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..42acd50 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.8 + +RUN apt-get update && apt-get install -y\ + rsync \ + openssh-client + +RUN pip install pipenv + +CMD ["/bin/bash"] diff --git a/Jenkinsfile b/Jenkinsfile index 3dba59f..5af169c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,16 +1,27 @@ pipeline { - agent none + agent { + dockerfile { + args "-u root" + } + } + environment { + SPHINXOPTS = '-w sphinx-build.log' + DEPLOY_HOST = 'docs@172.17.0.1' + DEPLOY_PATH = 'www/bot-base/' + } + stages { - stage('Test') { - agent { - docker { - image 'python:3.8' - } - } + stage('Install Dependencies') { steps { - sh "pip install --no-cache-dir -t python pipenv" - sh "PYTHONPATH=\$(pwd)/python PIPENV_VENV_IN_PROJECT=true python/bin/pipenv sync --sequential --dev" - sh "export PYTHONPATH=\$(pwd)/python && cd src && PIPENV_VENV_IN_PROJECT=true \${PYTHONPATH}/bin/pipenv run pytest -p no:warnings --junit-xml test-reports/results.xml" + sh 'pipenv sync --sequential --dev' + } + } + + stage('Run Tests') { + steps { + sh '''export PYTHONPATH=$(pwd)/python + cd src + pipenv run pytest -p no:warnings --junit-xml test-reports/results.xml''' } post { always { @@ -18,5 +29,38 @@ pipeline { } } } + + stage('Build Documentation') { + steps { + sh '''export PYTHONPATH=$(pwd)/python + cd doc + rm -f sphinx-build.log + pipenv run make html''' + } + post { + failure { + sh 'cat doc/sphinx-build.log' + } + } + } + + stage('Deploy Documentation') { + steps { + sshagent(credentials: ['1cf72f47-b70c-4f90-a958-020956099d19']) { + sh '''cd doc + rm -f rsync.log + ssh -o StrictHostKeyChecking=no -o BatchMode=yes ${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}${GIT_BRANCH#*/}/ + rsync -aze 'ssh -o StrictHostKeyChecking=no -o BatchMode=yes' \ + --log-file=rsync.log \ + --delete \ + ./build/html/ ${DEPLOY_HOST}:${DEPLOY_PATH}${GIT_BRANCH#*/}/''' + } + } + post { + failure { + sh 'cat doc/rsync.log' + } + } + } } } -- 2.44.2 From 7e36887d2b16f48fa6f1978cd6b435e94d38ad28 Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 14:58:29 +0200 Subject: [PATCH 02/13] Update docs location --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5af169c..060dbc2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { environment { SPHINXOPTS = '-w sphinx-build.log' DEPLOY_HOST = 'docs@172.17.0.1' - DEPLOY_PATH = 'www/bot-base/' + DEPLOY_PATH = 'www/docs/bot-base/' } stages { -- 2.44.2 From 64c048181e563647a8b037c1ba5fd3f878ca0a14 Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 15:50:01 +0200 Subject: [PATCH 03/13] Added global pipenv cache --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 060dbc2..c20f68f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent { dockerfile { - args "-u root" + args "-u root -v /var/lib/jenkins/pipenv:/root/.cache/pipenv:cached" } } environment { -- 2.44.2 From 07a03c059b0dc29d6ab926f50c7e8af9caee9eea Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 18:19:27 +0200 Subject: [PATCH 04/13] Trying to get the cache to work --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c20f68f..c395d9c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent { dockerfile { - args "-u root -v /var/lib/jenkins/pipenv:/root/.cache/pipenv:cached" + args "-u root -v $home/.cache/pipenv:/root/.cache/pipenv" } } environment { -- 2.44.2 From a9ae485db7be091bc151167d78d57f04dec5885b Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 18:24:26 +0200 Subject: [PATCH 05/13] Trying to get the cache to work --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c395d9c..3a9ca99 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent { dockerfile { - args "-u root -v $home/.cache/pipenv:/root/.cache/pipenv" + args "-u root -v $HOME/.cache/pipenv:/root/.cache/pipenv" } } environment { -- 2.44.2 From f1379a37465642c0956aa9826d350e255b6275da Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 18:26:31 +0200 Subject: [PATCH 06/13] Trying to get the cache to work --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3a9ca99..3b337b0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent { dockerfile { - args "-u root -v $HOME/.cache/pipenv:/root/.cache/pipenv" + args '-u root -v $HOME/.cache/pipenv:/root/.cache/pipenv' } } environment { -- 2.44.2 From a59e480f8541aee1bb0e125dc96bade50d5ef98e Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 18:33:19 +0200 Subject: [PATCH 07/13] Trying to get the cache to work --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3b337b0..ed462f5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent { dockerfile { - args '-u root -v $HOME/.cache/pipenv:/root/.cache/pipenv' + args '-u root -v $HOME/docker_volumes/.cache/:/root/.cache/' } } environment { -- 2.44.2 From 3cd86f728bf8c886738ad696daccfda75a8178ee Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 21:02:47 +0200 Subject: [PATCH 08/13] Deploy Documentation on condition --- Jenkinsfile | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ed462f5..1396217 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,15 +45,33 @@ pipeline { } stage('Deploy Documentation') { + when { + anyOf { + branch 'stable' + branch 'unstable' + tag + } + } steps { sshagent(credentials: ['1cf72f47-b70c-4f90-a958-020956099d19']) { - sh '''cd doc - rm -f rsync.log - ssh -o StrictHostKeyChecking=no -o BatchMode=yes ${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}${GIT_BRANCH#*/}/ - rsync -aze 'ssh -o StrictHostKeyChecking=no -o BatchMode=yes' \ - --log-file=rsync.log \ - --delete \ - ./build/html/ ${DEPLOY_HOST}:${DEPLOY_PATH}${GIT_BRANCH#*/}/''' + scipt { + SUB_PATH="""${sh( + returnStdout: true, + script: 'echo "${GIT_BRANCH#*/}"' + )}""".trim() + if (tag) { + SUB_PATH="${env.TAG_NAME}" + } + withEnv(["SUB_PATH=${SUB_PATH}"]) { + sh '''cd doc + rm -f rsync.log + ssh -o StrictHostKeyChecking=no -o BatchMode=yes ${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}${SUB_PATH}/ + rsync -aze 'ssh -o StrictHostKeyChecking=no -o BatchMode=yes' \ + --log-file=rsync.log \ + --delete \ + ./build/html/ ${DEPLOY_HOST}:${DEPLOY_PATH}${SUB_PATH}/''' + } + } } } post { -- 2.44.2 From aa30652a5a69a76e88304938abd6a1b6e6bfac6e Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 21:09:55 +0200 Subject: [PATCH 09/13] Trying to get the skip to work --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1396217..73f7d83 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -49,17 +49,17 @@ pipeline { anyOf { branch 'stable' branch 'unstable' - tag + buildingTag() } } steps { sshagent(credentials: ['1cf72f47-b70c-4f90-a958-020956099d19']) { scipt { - SUB_PATH="""${sh( + def SUB_PATH = """${sh( returnStdout: true, script: 'echo "${GIT_BRANCH#*/}"' )}""".trim() - if (tag) { + if (buildingTag()) { SUB_PATH="${env.TAG_NAME}" } withEnv(["SUB_PATH=${SUB_PATH}"]) { -- 2.44.2 From b9a2a0eb6d64856bc55c903f226482eb67530bdd Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 21:14:10 +0200 Subject: [PATCH 10/13] Trying to get the skip to work --- Jenkinsfile | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 73f7d83..ac2ca1c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,24 +53,25 @@ pipeline { } } steps { + scipt { + echo "Hello world" + def SUB_PATH = """${sh( + returnStdout: true, + script: 'echo "${GIT_BRANCH#*/}"' + )}""".trim() + if (buildingTag()) { + SUB_PATH="${env.TAG_NAME}" + } + } sshagent(credentials: ['1cf72f47-b70c-4f90-a958-020956099d19']) { - scipt { - def SUB_PATH = """${sh( - returnStdout: true, - script: 'echo "${GIT_BRANCH#*/}"' - )}""".trim() - if (buildingTag()) { - SUB_PATH="${env.TAG_NAME}" - } - withEnv(["SUB_PATH=${SUB_PATH}"]) { - sh '''cd doc - rm -f rsync.log - ssh -o StrictHostKeyChecking=no -o BatchMode=yes ${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}${SUB_PATH}/ - rsync -aze 'ssh -o StrictHostKeyChecking=no -o BatchMode=yes' \ - --log-file=rsync.log \ - --delete \ - ./build/html/ ${DEPLOY_HOST}:${DEPLOY_PATH}${SUB_PATH}/''' - } + withEnv(["SUB_PATH=${SUB_PATH}"]) { + sh '''cd doc + rm -f rsync.log + ssh -o StrictHostKeyChecking=no -o BatchMode=yes ${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}${SUB_PATH}/ + rsync -aze 'ssh -o StrictHostKeyChecking=no -o BatchMode=yes' \ + --log-file=rsync.log \ + --delete \ + ./build/html/ ${DEPLOY_HOST}:${DEPLOY_PATH}${SUB_PATH}/''' } } } -- 2.44.2 From bb20354c19e96d3bd705c3a585c143c25c3c6c5d Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 21:17:28 +0200 Subject: [PATCH 11/13] Trying to get the skip to work --- Jenkinsfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ac2ca1c..2cca48a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,16 +62,16 @@ pipeline { if (buildingTag()) { SUB_PATH="${env.TAG_NAME}" } - } - sshagent(credentials: ['1cf72f47-b70c-4f90-a958-020956099d19']) { - withEnv(["SUB_PATH=${SUB_PATH}"]) { - sh '''cd doc - rm -f rsync.log - ssh -o StrictHostKeyChecking=no -o BatchMode=yes ${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}${SUB_PATH}/ - rsync -aze 'ssh -o StrictHostKeyChecking=no -o BatchMode=yes' \ - --log-file=rsync.log \ - --delete \ - ./build/html/ ${DEPLOY_HOST}:${DEPLOY_PATH}${SUB_PATH}/''' + sshagent(credentials: ['1cf72f47-b70c-4f90-a958-020956099d19']) { + withEnv(["SUB_PATH=${SUB_PATH}"]) { + sh '''cd doc + rm -f rsync.log + ssh -o StrictHostKeyChecking=no -o BatchMode=yes ${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}${SUB_PATH}/ + rsync -aze 'ssh -o StrictHostKeyChecking=no -o BatchMode=yes' \ + --log-file=rsync.log \ + --delete \ + ./build/html/ ${DEPLOY_HOST}:${DEPLOY_PATH}${SUB_PATH}/''' + } } } } -- 2.44.2 From 81f63111e6cc3e0808fe4a81deb695336d38ba72 Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 21:19:32 +0200 Subject: [PATCH 12/13] Trying to get the skip to work --- Jenkinsfile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2cca48a..213dc6c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,7 +53,7 @@ pipeline { } } steps { - scipt { + script { echo "Hello world" def SUB_PATH = """${sh( returnStdout: true, @@ -62,16 +62,16 @@ pipeline { if (buildingTag()) { SUB_PATH="${env.TAG_NAME}" } - sshagent(credentials: ['1cf72f47-b70c-4f90-a958-020956099d19']) { - withEnv(["SUB_PATH=${SUB_PATH}"]) { - sh '''cd doc - rm -f rsync.log - ssh -o StrictHostKeyChecking=no -o BatchMode=yes ${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}${SUB_PATH}/ - rsync -aze 'ssh -o StrictHostKeyChecking=no -o BatchMode=yes' \ - --log-file=rsync.log \ - --delete \ - ./build/html/ ${DEPLOY_HOST}:${DEPLOY_PATH}${SUB_PATH}/''' - } + } + sshagent(credentials: ['1cf72f47-b70c-4f90-a958-020956099d19']) { + withEnv(["SUB_PATH=${SUB_PATH}"]) { + sh '''cd doc + rm -f rsync.log + ssh -o StrictHostKeyChecking=no -o BatchMode=yes ${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}${SUB_PATH}/ + rsync -aze 'ssh -o StrictHostKeyChecking=no -o BatchMode=yes' \ + --log-file=rsync.log \ + --delete \ + ./build/html/ ${DEPLOY_HOST}:${DEPLOY_PATH}${SUB_PATH}/''' } } } -- 2.44.2 From c27e1a3ef38d3184f4d7bd132f0f4a86349549eb Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 21:25:19 +0200 Subject: [PATCH 13/13] Trying to get the skip to work --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 213dc6c..ca6398e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { stages { stage('Install Dependencies') { steps { - sh 'pipenv sync --sequential --dev' + sh 'pipenv sync --dev' } } @@ -48,7 +48,7 @@ pipeline { when { anyOf { branch 'stable' - branch 'unstable' + branch 'master' buildingTag() } } -- 2.44.2