From 6768a955fadccde5f1b1321f25d191a93a862d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Fri, 10 Jan 2020 16:27:11 +0100 Subject: [PATCH 01/12] Configure Gitlab CI to use OpenStack. GNP-5711. --- .gitlab-ci.yml | 138 ++++++++++++++++------- backend/src/main/resources/bootstrap.yml | 1 + 2 files changed, 96 insertions(+), 43 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9c9fca69..c5c79e90 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,9 +2,9 @@ stages: - test - build - - beta - - staging - - production + - deploy-beta + - deploy-staging + - deploy-production image: urgi/docker-browsers:latest @@ -95,16 +95,16 @@ build: # Hidden job which serves as template for executed jobs below. # See https://docs.gitlab.com/ee/ci/yaml/#anchors retry: 2 - ## SSH initialization - before_script: + script: + ## SSH initialization - eval $(ssh-agent -s) - ssh-add <(echo "${SSH_PRIVATE_KEY}") - - ssh -o StrictHostKeyChecking=no root@${SERVER_IP} 'echo "Successfully connected on $(hostname)"' - script: + - ssh -o StrictHostKeyChecking=no ${SERVER_USER}@${SERVER_IP} 'echo "Successfully connected on $(hostname)"' # Copy jar - - scp ./$JAR_PATH root@${SERVER_IP}:/opt/bootapp/${APP_NAME}-${ENV}.jar + - scp ./backend/build/libs/${APP_NAME}.jar ${SERVER_USER}@${SERVER_IP}:/tmp/${APP_NAME}-${ENV}.jar + - ssh ${SERVER_USER}@${SERVER_IP} "sudo mv /tmp/${APP_NAME}-${ENV}.jar /opt/bootapp/${APP_NAME}-${ENV}.jar ; sudo chown -R bootapp:bootapp /opt/bootapp/" # Restarting service with the updated jar and the according Spring profiles enabled - - ssh root@${SERVER_IP} "systemctl restart bootapp@${APP_NAME}-${ENV}" + - ssh ${SERVER_USER}@${SERVER_IP} "sudo systemctl restart bootapp@${APP_NAME}-${ENV}" - eval $(ssh-agent -k) - echo "Deploy done. Application should be available at http://${SERVER_IP}:${APP_PORT}/${CONTEXT_PATH}" only: @@ -113,25 +113,66 @@ build: - backend/src/**/* - frontend/**/* +.static_variables: + variables: + APP_NAME: faidare + ES_PORT: ${ES_DEV_PORT} + APP_CONTEXT: ${APP_NAME}-${ENV} -deploy-to-staging: - stage: staging +.openstack_variables: + variables: + SERVER_IP: ${SERVER_IP_OPENSTACK} + SERVER_USER: ${SERVER_USER_OPENSTACK} + ES_HOST: ${ES_DEV_HOST_OPENSTACK} + ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} + +.variables-beta-openstack: + extends: + - .static_variables + - .openstack_variables + variables: + ENV: beta + APP_PORT: ${BETA_FAIDARE_PORT} + CONTEXT_PATH: ${BETA_FAIDARE_CONTEXT_PATH} + +.variables-staging-openstack: + extends: + - .static_variables + - .openstack_variables variables: ENV: staging - APP_PORT: ${STAGING_GPDS_PORT} - CONTEXT_PATH: ${STAGING_GPDS_CONTEXT_PATH} - <<: *deploy_to_vm - only: - refs: - - branches - except: - refs: - - master - when: manual - allow_failure: false + APP_PORT: ${STAGING_FAIDARE_PORT} + CONTEXT_PATH: ${STAGING_FAIDARE_CONTEXT_PATH} + +.variables-int-openstack: + extends: + - .static_variables + - .openstack_variables + variables: + ENV: int + APP_PORT: ${INT_FAIDARE_PORT} + CONTEXT_PATH: ${INT_FAIDARE_CONTEXT_PATH} + +.variables-prod-public-openstack: + extends: .static_variables + extends: .openstack_variables + variables: + ENV: prod-public + APP_PORT: ${PROD_PUBLIC_FAIDARE_PORT} + CONTEXT_PATH: ${PROD_PUBLIC_FAIDARE_CONTEXT_PATH} + +.variables-prod-private-openstack: + extends: + - .static_variables + - .openstack_variables + variables: + ENV: prod-private + APP_PORT: ${PROD_PRIVATE_FAIDARE_PORT} + CONTEXT_PATH: ${PROD_PRIVATE_FAIDARE_CONTEXT_PATH} + deploy-to-beta: - stage: beta + stage: deploy-beta variables: ENV: beta APP_PORT: ${BETA_GPDS_PORT} @@ -143,43 +184,54 @@ deploy-to-beta: only: refs: - branches + changes: + - .gitlab-ci.yml + - backend/src/**/* + - frontend/**/* + when: always allow_failure: false -deploy-to-int: - stage: production - variables: - ENV: int - APP_PORT: ${INT_GPDS_PORT} - CONTEXT_PATH: ${INT_GPDS_CONTEXT_PATH} - <<: *deploy_to_vm +deploy-to-staging: + stage: deploy-staging + extends: + - .variables-staging-openstack + - .deploy-to-vm only: + refs: + - branches + except: refs: - master when: manual allow_failure: false +deploy-to-int: + stage: deploy-production + extends: + - .variables-int-openstack + - .deploy-to-vm + only: + refs: + - master + when: manual + allow_failure: false deploy-to-prod-public: - stage: production - variables: - ENV: prod-public - APP_PORT: ${PROD_PUBLIC_GPDS_PORT} - CONTEXT_PATH: ${PROD_PUBLIC_GPDS_CONTEXT_PATH} - <<: *deploy_to_vm + stage: deploy-production + extends: + - .variables-prod-public-openstack + - .deploy-to-vm only: refs: - master when: manual allow_failure: false - deploy-to-prod-private: - stage: production - variables: - ENV: prod-private - APP_PORT: ${PROD_PRIVATE_GPDS_PORT} - CONTEXT_PATH: ${PROD_PRIVATE_GPDS_CONTEXT_PATH} - <<: *deploy_to_vm + stage: deploy-production + extends: + - .variables-prod-private-openstack + - .deploy-to-vm only: refs: - master diff --git a/backend/src/main/resources/bootstrap.yml b/backend/src/main/resources/bootstrap.yml index c2bfdecd..b763e119 100644 --- a/backend/src/main/resources/bootstrap.yml +++ b/backend/src/main/resources/bootstrap.yml @@ -3,3 +3,4 @@ spring: cloud: config: uri: ${SPRING_CONFIG_URI:http://localhost:8888} + label: feat(_)configure_openstack_ci -- GitLab From ddbb42df888632afd5cddd635be510d2d5e87ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Fri, 10 Jan 2020 17:03:44 +0100 Subject: [PATCH 02/12] Add missing tags. GNP-5711. --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c5c79e90..19e4e96e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,6 +95,8 @@ build: # Hidden job which serves as template for executed jobs below. # See https://docs.gitlab.com/ee/ci/yaml/#anchors retry: 2 + tags: + - openstack script: ## SSH initialization - eval $(ssh-agent -s) -- GitLab From 7db25560c406cc4a84e958e95833fda93ff2a76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Fri, 10 Jan 2020 17:53:44 +0100 Subject: [PATCH 03/12] Use array for extends instead of several invocations. --- .gitlab-ci.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 19e4e96e..029e1f72 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -156,8 +156,9 @@ build: CONTEXT_PATH: ${INT_FAIDARE_CONTEXT_PATH} .variables-prod-public-openstack: - extends: .static_variables - extends: .openstack_variables + extends: + - .static_variables + - .openstack_variables variables: ENV: prod-public APP_PORT: ${PROD_PUBLIC_FAIDARE_PORT} @@ -172,20 +173,19 @@ build: APP_PORT: ${PROD_PRIVATE_FAIDARE_PORT} CONTEXT_PATH: ${PROD_PRIVATE_FAIDARE_CONTEXT_PATH} - deploy-to-beta: stage: deploy-beta - variables: - ENV: beta - APP_PORT: ${BETA_GPDS_PORT} - CONTEXT_PATH: ${BETA_GPDS_CONTEXT_PATH} - <<: *deploy_to_vm + extends: + - .variables-beta-openstack + - .deploy-to-vm except: refs: - master only: refs: - - branches + # swap both below when merging + # - branches + - feat/configure_openstack_ci changes: - .gitlab-ci.yml - backend/src/**/* -- GitLab From 41eee60967155912b7b680dba9c22cfb7be57d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Fri, 10 Jan 2020 17:54:24 +0100 Subject: [PATCH 04/12] Move variable definition into concrete job for beta. GNP-5711. --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 029e1f72..52ed31b7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -175,6 +175,11 @@ build: deploy-to-beta: stage: deploy-beta + variables: + SERVER_IP: ${SERVER_IP_OPENSTACK} + SERVER_USER: ${SERVER_USER_OPENSTACK} + ES_HOST: ${ES_DEV_HOST_OPENSTACK} + ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} extends: - .variables-beta-openstack - .deploy-to-vm -- GitLab From 16c4af49dae48b7ccabe79c8d116d05eaee9cb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Fri, 10 Jan 2020 18:14:05 +0100 Subject: [PATCH 05/12] Use YAML anchors instead of extends keyword which does not handle variables expansion correctly. GNP-5711. --- .gitlab-ci.yml | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 52ed31b7..4d090075 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -115,29 +115,31 @@ build: - backend/src/**/* - frontend/**/* -.static_variables: +.static_variables: &static_variables variables: APP_NAME: faidare ES_PORT: ${ES_DEV_PORT} APP_CONTEXT: ${APP_NAME}-${ENV} -.openstack_variables: +.openstack_variables: &openstack_variables variables: SERVER_IP: ${SERVER_IP_OPENSTACK} SERVER_USER: ${SERVER_USER_OPENSTACK} ES_HOST: ${ES_DEV_HOST_OPENSTACK} ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} -.variables-beta-openstack: - extends: - - .static_variables - - .openstack_variables +.variables-beta-openstack: &variables-beta-openstack + # extends: + # - .static_variables + # - .openstack_variables + <<: *static_variables + <<: *openstack_variables variables: ENV: beta APP_PORT: ${BETA_FAIDARE_PORT} CONTEXT_PATH: ${BETA_FAIDARE_CONTEXT_PATH} -.variables-staging-openstack: +.variables-staging-openstack: &variables-staging-openstack extends: - .static_variables - .openstack_variables @@ -146,7 +148,7 @@ build: APP_PORT: ${STAGING_FAIDARE_PORT} CONTEXT_PATH: ${STAGING_FAIDARE_CONTEXT_PATH} -.variables-int-openstack: +.variables-int-openstack: &variables-int-openstack extends: - .static_variables - .openstack_variables @@ -155,7 +157,7 @@ build: APP_PORT: ${INT_FAIDARE_PORT} CONTEXT_PATH: ${INT_FAIDARE_CONTEXT_PATH} -.variables-prod-public-openstack: +.variables-prod-public-openstack: &variables-prod-public-openstack extends: - .static_variables - .openstack_variables @@ -164,7 +166,7 @@ build: APP_PORT: ${PROD_PUBLIC_FAIDARE_PORT} CONTEXT_PATH: ${PROD_PUBLIC_FAIDARE_CONTEXT_PATH} -.variables-prod-private-openstack: +.variables-prod-private-openstack: &variables-prod-private-openstack extends: - .static_variables - .openstack_variables @@ -175,14 +177,11 @@ build: deploy-to-beta: stage: deploy-beta - variables: - SERVER_IP: ${SERVER_IP_OPENSTACK} - SERVER_USER: ${SERVER_USER_OPENSTACK} - ES_HOST: ${ES_DEV_HOST_OPENSTACK} - ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} - extends: - - .variables-beta-openstack - - .deploy-to-vm + # extends: + # - .variables-beta-openstack + # - .deploy-to-vm + <<: *variables-beta-openstack + <<: *deploy_to_vm except: refs: - master -- GitLab From 1dc2dc64f00d251aee9c8c1932cc073107b9b826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Fri, 10 Jan 2020 18:34:21 +0100 Subject: [PATCH 06/12] Merge all variables into ony one hidden job. --- .gitlab-ci.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4d090075..2072c2f8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -123,6 +123,9 @@ build: .openstack_variables: &openstack_variables variables: + APP_NAME: faidare + ES_PORT: ${ES_DEV_PORT} + APP_CONTEXT: ${APP_NAME}-${ENV} SERVER_IP: ${SERVER_IP_OPENSTACK} SERVER_USER: ${SERVER_USER_OPENSTACK} ES_HOST: ${ES_DEV_HOST_OPENSTACK} @@ -132,12 +135,18 @@ build: # extends: # - .static_variables # - .openstack_variables - <<: *static_variables - <<: *openstack_variables + # <<: *static_variables + # <<: *openstack_variables variables: ENV: beta APP_PORT: ${BETA_FAIDARE_PORT} + APP_NAME: faidare CONTEXT_PATH: ${BETA_FAIDARE_CONTEXT_PATH} + SERVER_IP: ${SERVER_IP_OPENSTACK} + SERVER_USER: ${SERVER_USER_OPENSTACK} + ES_PORT: ${ES_DEV_PORT} + ES_HOST: ${ES_DEV_HOST_OPENSTACK} + ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} .variables-staging-openstack: &variables-staging-openstack extends: @@ -153,7 +162,7 @@ build: - .static_variables - .openstack_variables variables: - ENV: int + ENV: intSERVER_USER APP_PORT: ${INT_FAIDARE_PORT} CONTEXT_PATH: ${INT_FAIDARE_CONTEXT_PATH} -- GitLab From 95c44d204bb078a05e01e5fd72ce5d8f40790207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Fri, 10 Jan 2020 18:43:22 +0100 Subject: [PATCH 07/12] Create deploy-to-vm-openstack specific job. --- .gitlab-ci.yml | 65 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2072c2f8..91a896b4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,8 +95,6 @@ build: # Hidden job which serves as template for executed jobs below. # See https://docs.gitlab.com/ee/ci/yaml/#anchors retry: 2 - tags: - - openstack script: ## SSH initialization - eval $(ssh-agent -s) @@ -115,21 +113,42 @@ build: - backend/src/**/* - frontend/**/* -.static_variables: &static_variables - variables: - APP_NAME: faidare - ES_PORT: ${ES_DEV_PORT} - APP_CONTEXT: ${APP_NAME}-${ENV} -.openstack_variables: &openstack_variables +.deploy-to-vm-openstack: &deploy_to_vm_openstack + # Hidden job which serves as template for executed jobs below. + # See https://docs.gitlab.com/ee/ci/yaml/#anchors + retry: 2 + tags: + - openstack variables: APP_NAME: faidare - ES_PORT: ${ES_DEV_PORT} - APP_CONTEXT: ${APP_NAME}-${ENV} - SERVER_IP: ${SERVER_IP_OPENSTACK} - SERVER_USER: ${SERVER_USER_OPENSTACK} - ES_HOST: ${ES_DEV_HOST_OPENSTACK} - ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} + script: + ## SSH initialization + - eval $(ssh-agent -s) + - ssh-add <(echo "${SSH_PRIVATE_KEY}") + - echo "ssh -o StrictHostKeyChecking=no ${SERVER_USER_OPENSTACK}@${SERVER_IP_OPENSTACK}" + - ssh -o StrictHostKeyChecking=no ${SERVER_USER_OPENSTACK}@${SERVER_IP_OPENSTACK} 'echo "Successfully connected on $(hostname)"' + # Copy jar + - scp ./backend/build/libs/${APP_NAME}.jar ${SERVER_USER_OPENSTACK}@${SERVER_IP_OPENSTACK}:/tmp/${APP_NAME}-${ENV}.jar + - ssh ${SERVER_USER_OPENSTACK}@${SERVER_IP_OPENSTACK} "sudo mv /tmp/${APP_NAME}-${ENV}.jar /opt/bootapp/${APP_NAME}-${ENV}.jar ; sudo chown -R bootapp:bootapp /opt/bootapp/" + # Restarting service with the updated jar and the according Spring profiles enabled + - ssh ${SERVER_USER_OPENSTACK}@${SERVER_IP_OPENSTACK} "sudo systemctl restart bootapp@${APP_NAME}-${ENV}" + - eval $(ssh-agent -k) + - echo "Deploy done. Application should be available at http://${SERVER_IP_OPENSTACK}:${APP_PORT}/${CONTEXT_PATH}" + +# .static_variables: &static_variables +# variables: +# APP_NAME: faidare +# ES_PORT: ${ES_DEV_PORT} + +# .openstack_variables: &openstack_variables +# variables: +# APP_NAME: faidare +# ES_PORT: ${ES_DEV_PORT} +# SERVER_IP: ${SERVER_IP_OPENSTACK} +# SERVER_USER: ${SERVER_USER_OPENSTACK} +# ES_HOST: ${ES_DEV_HOST_OPENSTACK} +# ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} .variables-beta-openstack: &variables-beta-openstack # extends: @@ -186,11 +205,21 @@ build: deploy-to-beta: stage: deploy-beta - # extends: + extends: # - .variables-beta-openstack - # - .deploy-to-vm - <<: *variables-beta-openstack - <<: *deploy_to_vm + - .deploy-to-vm-openstack + # <<: *variables-beta-openstack + # <<: *deploy_to_vm_openstack + variables: + ENV: beta + APP_PORT: ${BETA_FAIDARE_PORT} + # APP_NAME: faidare + CONTEXT_PATH: faidare-beta + # SERVER_IP: ${SERVER_IP_OPENSTACK} + # SERVER_USER: ${SERVER_USER_OPENSTACK} + # ES_PORT: ${ES_DEV_PORT} + # ES_HOST: ${ES_DEV_HOST_OPENSTACK} + # ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} except: refs: - master -- GitLab From 74dc55c6952464f56045d7124cbdef09fbe1cb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Fri, 10 Jan 2020 18:44:28 +0100 Subject: [PATCH 08/12] Fix yaml syntax error. --- .gitlab-ci.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 91a896b4..32a1c9ff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -136,19 +136,19 @@ build: - eval $(ssh-agent -k) - echo "Deploy done. Application should be available at http://${SERVER_IP_OPENSTACK}:${APP_PORT}/${CONTEXT_PATH}" -# .static_variables: &static_variables -# variables: -# APP_NAME: faidare -# ES_PORT: ${ES_DEV_PORT} - -# .openstack_variables: &openstack_variables -# variables: -# APP_NAME: faidare -# ES_PORT: ${ES_DEV_PORT} -# SERVER_IP: ${SERVER_IP_OPENSTACK} -# SERVER_USER: ${SERVER_USER_OPENSTACK} -# ES_HOST: ${ES_DEV_HOST_OPENSTACK} -# ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} +.static_variables: &static_variables + variables: + APP_NAME: faidare + ES_PORT: ${ES_DEV_PORT} + +.openstack_variables: &openstack_variables + variables: + APP_NAME: faidare + ES_PORT: ${ES_DEV_PORT} + SERVER_IP: ${SERVER_IP_OPENSTACK} + SERVER_USER: ${SERVER_USER_OPENSTACK} + ES_HOST: ${ES_DEV_HOST_OPENSTACK} + ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} .variables-beta-openstack: &variables-beta-openstack # extends: -- GitLab From 8afd02a7934fdd74d28c15fe78d198d99bae8c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Fri, 10 Jan 2020 18:53:14 +0100 Subject: [PATCH 09/12] Remove all useless variables stuff --- .gitlab-ci.yml | 115 ++++++++++--------------------------------------- 1 file changed, 22 insertions(+), 93 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 32a1c9ff..555d0326 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -120,13 +120,10 @@ build: retry: 2 tags: - openstack - variables: - APP_NAME: faidare script: ## SSH initialization - eval $(ssh-agent -s) - ssh-add <(echo "${SSH_PRIVATE_KEY}") - - echo "ssh -o StrictHostKeyChecking=no ${SERVER_USER_OPENSTACK}@${SERVER_IP_OPENSTACK}" - ssh -o StrictHostKeyChecking=no ${SERVER_USER_OPENSTACK}@${SERVER_IP_OPENSTACK} 'echo "Successfully connected on $(hostname)"' # Copy jar - scp ./backend/build/libs/${APP_NAME}.jar ${SERVER_USER_OPENSTACK}@${SERVER_IP_OPENSTACK}:/tmp/${APP_NAME}-${ENV}.jar @@ -136,90 +133,14 @@ build: - eval $(ssh-agent -k) - echo "Deploy done. Application should be available at http://${SERVER_IP_OPENSTACK}:${APP_PORT}/${CONTEXT_PATH}" -.static_variables: &static_variables - variables: - APP_NAME: faidare - ES_PORT: ${ES_DEV_PORT} - -.openstack_variables: &openstack_variables - variables: - APP_NAME: faidare - ES_PORT: ${ES_DEV_PORT} - SERVER_IP: ${SERVER_IP_OPENSTACK} - SERVER_USER: ${SERVER_USER_OPENSTACK} - ES_HOST: ${ES_DEV_HOST_OPENSTACK} - ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} - -.variables-beta-openstack: &variables-beta-openstack - # extends: - # - .static_variables - # - .openstack_variables - # <<: *static_variables - # <<: *openstack_variables - variables: - ENV: beta - APP_PORT: ${BETA_FAIDARE_PORT} - APP_NAME: faidare - CONTEXT_PATH: ${BETA_FAIDARE_CONTEXT_PATH} - SERVER_IP: ${SERVER_IP_OPENSTACK} - SERVER_USER: ${SERVER_USER_OPENSTACK} - ES_PORT: ${ES_DEV_PORT} - ES_HOST: ${ES_DEV_HOST_OPENSTACK} - ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} - -.variables-staging-openstack: &variables-staging-openstack - extends: - - .static_variables - - .openstack_variables - variables: - ENV: staging - APP_PORT: ${STAGING_FAIDARE_PORT} - CONTEXT_PATH: ${STAGING_FAIDARE_CONTEXT_PATH} - -.variables-int-openstack: &variables-int-openstack - extends: - - .static_variables - - .openstack_variables - variables: - ENV: intSERVER_USER - APP_PORT: ${INT_FAIDARE_PORT} - CONTEXT_PATH: ${INT_FAIDARE_CONTEXT_PATH} - -.variables-prod-public-openstack: &variables-prod-public-openstack - extends: - - .static_variables - - .openstack_variables - variables: - ENV: prod-public - APP_PORT: ${PROD_PUBLIC_FAIDARE_PORT} - CONTEXT_PATH: ${PROD_PUBLIC_FAIDARE_CONTEXT_PATH} - -.variables-prod-private-openstack: &variables-prod-private-openstack - extends: - - .static_variables - - .openstack_variables - variables: - ENV: prod-private - APP_PORT: ${PROD_PRIVATE_FAIDARE_PORT} - CONTEXT_PATH: ${PROD_PRIVATE_FAIDARE_CONTEXT_PATH} deploy-to-beta: stage: deploy-beta - extends: - # - .variables-beta-openstack - - .deploy-to-vm-openstack - # <<: *variables-beta-openstack - # <<: *deploy_to_vm_openstack + extends: .deploy-to-vm-openstack variables: - ENV: beta APP_PORT: ${BETA_FAIDARE_PORT} - # APP_NAME: faidare + ENV: beta CONTEXT_PATH: faidare-beta - # SERVER_IP: ${SERVER_IP_OPENSTACK} - # SERVER_USER: ${SERVER_USER_OPENSTACK} - # ES_PORT: ${ES_DEV_PORT} - # ES_HOST: ${ES_DEV_HOST_OPENSTACK} - # ES_HOSTS: ${ES_DEV_HOSTS_OPENSTACK} except: refs: - master @@ -237,9 +158,11 @@ deploy-to-beta: deploy-to-staging: stage: deploy-staging - extends: - - .variables-staging-openstack - - .deploy-to-vm + extends: .deploy-to-vm-openstack + variables: + APP_PORT: ${STAGING_FAIDARE_PORT} + ENV: staging + CONTEXT_PATH: faidare-staging only: refs: - branches @@ -251,9 +174,11 @@ deploy-to-staging: deploy-to-int: stage: deploy-production - extends: - - .variables-int-openstack - - .deploy-to-vm + extends: .deploy-to-vm-openstack + variables: + APP_PORT: ${INT_FAIDARE_PORT} + ENV: int + CONTEXT_PATH: faidare-int only: refs: - master @@ -262,9 +187,11 @@ deploy-to-int: deploy-to-prod-public: stage: deploy-production - extends: - - .variables-prod-public-openstack - - .deploy-to-vm + extends: .deploy-to-vm-openstack + variables: + APP_PORT: ${PROD_PUBLIC_FAIDARE_PORT} + ENV: prod-public + CONTEXT_PATH: faidare only: refs: - master @@ -273,9 +200,11 @@ deploy-to-prod-public: deploy-to-prod-private: stage: deploy-production - extends: - - .variables-prod-private-openstack - - .deploy-to-vm + extends: .deploy-to-vm-openstack + variables: + APP_PORT: ${PROD_PRIVATE_FAIDARE_PORT} + ENV: prod-private + CONTEXT_PATH: faidare-private only: refs: - master -- GitLab From f6c25b69bf1ff585e801eb1daba217b8914dd27a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Fri, 10 Jan 2020 19:26:00 +0100 Subject: [PATCH 10/12] Simplify gitlab-ci.yml. GNP-5711. --- .gitlab-ci.yml | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 555d0326..ad1007f0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -120,6 +120,11 @@ build: retry: 2 tags: - openstack + only: + changes: + - .gitlab-ci.yml + - backend/src/**/* + - frontend/**/* script: ## SSH initialization - eval $(ssh-agent -s) @@ -132,7 +137,8 @@ build: - ssh ${SERVER_USER_OPENSTACK}@${SERVER_IP_OPENSTACK} "sudo systemctl restart bootapp@${APP_NAME}-${ENV}" - eval $(ssh-agent -k) - echo "Deploy done. Application should be available at http://${SERVER_IP_OPENSTACK}:${APP_PORT}/${CONTEXT_PATH}" - + when: manual + allow_failure: false deploy-to-beta: stage: deploy-beta @@ -149,12 +155,7 @@ deploy-to-beta: # swap both below when merging # - branches - feat/configure_openstack_ci - changes: - - .gitlab-ci.yml - - backend/src/**/* - - frontend/**/* when: always - allow_failure: false deploy-to-staging: stage: deploy-staging @@ -163,14 +164,7 @@ deploy-to-staging: APP_PORT: ${STAGING_FAIDARE_PORT} ENV: staging CONTEXT_PATH: faidare-staging - only: - refs: - - branches - except: - refs: - - master when: manual - allow_failure: false deploy-to-int: stage: deploy-production @@ -179,11 +173,7 @@ deploy-to-int: APP_PORT: ${INT_FAIDARE_PORT} ENV: int CONTEXT_PATH: faidare-int - only: - refs: - - master when: manual - allow_failure: false deploy-to-prod-public: stage: deploy-production @@ -192,11 +182,7 @@ deploy-to-prod-public: APP_PORT: ${PROD_PUBLIC_FAIDARE_PORT} ENV: prod-public CONTEXT_PATH: faidare - only: - refs: - - master when: manual - allow_failure: false deploy-to-prod-private: stage: deploy-production @@ -205,8 +191,5 @@ deploy-to-prod-private: APP_PORT: ${PROD_PRIVATE_FAIDARE_PORT} ENV: prod-private CONTEXT_PATH: faidare-private - only: - refs: - - master when: manual - allow_failure: false + -- GitLab From 32e923b1db8f3b3171205e8832f2140fab60ad54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Mon, 10 Feb 2020 17:57:40 +0100 Subject: [PATCH 11/12] Fix CI after rebase. --- .gitlab-ci.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad1007f0..ad933d37 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -120,11 +120,6 @@ build: retry: 2 tags: - openstack - only: - changes: - - .gitlab-ci.yml - - backend/src/**/* - - frontend/**/* script: ## SSH initialization - eval $(ssh-agent -s) @@ -137,6 +132,11 @@ build: - ssh ${SERVER_USER_OPENSTACK}@${SERVER_IP_OPENSTACK} "sudo systemctl restart bootapp@${APP_NAME}-${ENV}" - eval $(ssh-agent -k) - echo "Deploy done. Application should be available at http://${SERVER_IP_OPENSTACK}:${APP_PORT}/${CONTEXT_PATH}" + only: + changes: + - .gitlab-ci.yml + - backend/src/**/* + - frontend/**/* when: manual allow_failure: false @@ -164,6 +164,14 @@ deploy-to-staging: APP_PORT: ${STAGING_FAIDARE_PORT} ENV: staging CONTEXT_PATH: faidare-staging + only: + refs: + # swap both below when merging + # - branches + - feat/configure_openstack_ci + except: + refs: + - master when: manual deploy-to-int: @@ -173,6 +181,9 @@ deploy-to-int: APP_PORT: ${INT_FAIDARE_PORT} ENV: int CONTEXT_PATH: faidare-int + only: + refs: + - master when: manual deploy-to-prod-public: @@ -182,6 +193,9 @@ deploy-to-prod-public: APP_PORT: ${PROD_PUBLIC_FAIDARE_PORT} ENV: prod-public CONTEXT_PATH: faidare + only: + refs: + - master when: manual deploy-to-prod-private: @@ -191,5 +205,8 @@ deploy-to-prod-private: APP_PORT: ${PROD_PRIVATE_FAIDARE_PORT} ENV: prod-private CONTEXT_PATH: faidare-private + only: + refs: + - master when: manual -- GitLab From 39fa06e6c78e2bcd5101c4a4916d6026f5aa71e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inra.fr> Date: Thu, 12 Mar 2020 18:23:01 +0100 Subject: [PATCH 12/12] Remove branch specific stuff --- .gitlab-ci.yml | 16 ++++++---------- backend/src/main/resources/bootstrap.yml | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad933d37..4066607a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -91,7 +91,7 @@ build: # DEPLOY -.deploy-to-vm: &deploy_to_vm +.deploy-to-vm-proxmox: &deploy_to_vm_proxmox # Hidden job which serves as template for executed jobs below. # See https://docs.gitlab.com/ee/ci/yaml/#anchors retry: 2 @@ -152,9 +152,7 @@ deploy-to-beta: - master only: refs: - # swap both below when merging - # - branches - - feat/configure_openstack_ci + - branches when: always deploy-to-staging: @@ -166,9 +164,7 @@ deploy-to-staging: CONTEXT_PATH: faidare-staging only: refs: - # swap both below when merging - # - branches - - feat/configure_openstack_ci + - branches except: refs: - master @@ -176,7 +172,7 @@ deploy-to-staging: deploy-to-int: stage: deploy-production - extends: .deploy-to-vm-openstack + extends: .deploy-to-vm-proxmox variables: APP_PORT: ${INT_FAIDARE_PORT} ENV: int @@ -188,7 +184,7 @@ deploy-to-int: deploy-to-prod-public: stage: deploy-production - extends: .deploy-to-vm-openstack + extends: .deploy-to-vm-proxmox variables: APP_PORT: ${PROD_PUBLIC_FAIDARE_PORT} ENV: prod-public @@ -200,7 +196,7 @@ deploy-to-prod-public: deploy-to-prod-private: stage: deploy-production - extends: .deploy-to-vm-openstack + extends: .deploy-to-vm-proxmox variables: APP_PORT: ${PROD_PRIVATE_FAIDARE_PORT} ENV: prod-private diff --git a/backend/src/main/resources/bootstrap.yml b/backend/src/main/resources/bootstrap.yml index b763e119..3be3a00c 100644 --- a/backend/src/main/resources/bootstrap.yml +++ b/backend/src/main/resources/bootstrap.yml @@ -3,4 +3,4 @@ spring: cloud: config: uri: ${SPRING_CONFIG_URI:http://localhost:8888} - label: feat(_)configure_openstack_ci + # label: feat(_)configure_openstack_ci -- GitLab