From 2e6ff3a5cf8c57877629f09df1c031eb1379b356 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Fri, 3 May 2019 19:19:09 +0200 Subject: [PATCH 1/4] MON-449 global ci to build template stack and terraform apply --- .gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 087b35a..81723a9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,8 +2,10 @@ image: hashicorp/terraform:full stages: - test + - build + - deploy -test_auto_update: +auto_update: stage: test script: - apk update @@ -18,3 +20,33 @@ test_auto_update: - product-teams - kubernetes - gke + +deploy_terraform: + stage: deploy + script: + - apk update + - apk upgrade + - apk add --no-cache curl + - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=MON-182_minimal_v1 -F 'variables[SCENARIO]=test' https://git.fr.clara.net/api/v4/projects/513/trigger/pipeline" + only: + - master + tags: + - product-teams + - kubernetes + - gke + +build_template: + stage: build + script: + - apk update + - apk upgrade + - apk add --no-cache curl + - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=MON-182_minimal_v1 -F 'variables[SCENARIO]=build' https://git.fr.clara.net/api/v4/projects/513/trigger/pipeline" + only: + - tags + except: + - branches + tags: + - product-teams + - kubernetes + - gke From f9012ff3021068036d4429116b244c8aed9ebaa9 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Fri, 3 May 2019 20:52:43 +0200 Subject: [PATCH 2/4] MON-449 add tag to build --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 81723a9..fd5fd13 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ deploy_terraform: - apk update - apk upgrade - apk add --no-cache curl - - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=MON-182_minimal_v1 -F 'variables[SCENARIO]=test' https://git.fr.clara.net/api/v4/projects/513/trigger/pipeline" + - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=MON-182_minimal_v1 -F \"variables[SCENARIO]=test\" https://git.fr.clara.net/api/v4/projects/513/trigger/pipeline" only: - master tags: @@ -41,7 +41,7 @@ build_template: - apk update - apk upgrade - apk add --no-cache curl - - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=MON-182_minimal_v1 -F 'variables[SCENARIO]=build' https://git.fr.clara.net/api/v4/projects/513/trigger/pipeline" + - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=MON-182_minimal_v1 -F \"variables[SCENARIO]=build\" -F \"variables[TAG]=$CI_COMMIT_TAG\" https://git.fr.clara.net/api/v4/projects/513/trigger/pipeline" only: - tags except: From 24810b5e0fb1e313268712acf43cd381ce833721 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 6 May 2019 10:39:07 +0200 Subject: [PATCH 3/4] MON-449 use alpine image instead of terraform full --- .gitlab-ci.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd5fd13..138ec65 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,16 +1,20 @@ -image: hashicorp/terraform:full +image: alpine:latest stages: - test - build - deploy +before_script: + - apk update + - apk upgrade + - apk add --no-cache curl + auto_update: + image: hashicorp/terraform:full stage: test script: - - apk update - - apk upgrade - - apk add --no-cache bash git grep coreutils curl + - apk add --no-cache bash git grep coreutils - curl -Lo /usr/local/bin/terraform-docs "https://github.com/$(curl -s https://github.com/segmentio/terraform-docs/releases | grep terraform-docs-v0.6.0-linux-amd | head -n 1 | cut -d '"' -f 2)" - chmod +x /usr/local/bin/terraform-docs - ./scripts/auto_update.sh ./ @@ -24,9 +28,6 @@ auto_update: deploy_terraform: stage: deploy script: - - apk update - - apk upgrade - - apk add --no-cache curl - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=MON-182_minimal_v1 -F \"variables[SCENARIO]=test\" https://git.fr.clara.net/api/v4/projects/513/trigger/pipeline" only: - master @@ -38,9 +39,6 @@ deploy_terraform: build_template: stage: build script: - - apk update - - apk upgrade - - apk add --no-cache curl - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=MON-182_minimal_v1 -F \"variables[SCENARIO]=build\" -F \"variables[TAG]=$CI_COMMIT_TAG\" https://git.fr.clara.net/api/v4/projects/513/trigger/pipeline" only: - tags From 2aedfa81c6cad22a0fc35db605173fe48871416a Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 6 May 2019 10:55:32 +0200 Subject: [PATCH 4/4] MON-449 use variables for curl to templates ci --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 138ec65..991fb27 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,7 +28,7 @@ auto_update: deploy_terraform: stage: deploy script: - - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=MON-182_minimal_v1 -F \"variables[SCENARIO]=test\" https://git.fr.clara.net/api/v4/projects/513/trigger/pipeline" + - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=${TEMPLATES_GITLAB_BRANCH:-master} -F \"variables[SCENARIO]=test\" ${CI_API_V4_URL}/projects/${TEMPLATES_GITLAB_ID}/trigger/pipeline" only: - master tags: @@ -39,7 +39,7 @@ deploy_terraform: build_template: stage: build script: - - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=MON-182_minimal_v1 -F \"variables[SCENARIO]=build\" -F \"variables[TAG]=$CI_COMMIT_TAG\" https://git.fr.clara.net/api/v4/projects/513/trigger/pipeline" + - "curl -X POST -F token=${TEMPLATES_GITLAB_TOKEN} -F ref=${TEMPLATES_GITLAB_BRANCH:-master} -F \"variables[SCENARIO]=build\" -F \"variables[TAG]=$CI_COMMIT_TAG\" ${CI_API_V4_URL}/projects/${TEMPLATES_GITLAB_ID}/trigger/pipeline" only: - tags except: