Skip to content
Snippets Groups Projects
Commit 0c4149f2ff49 authored by Simon Chabot's avatar Simon Chabot
Browse files

ci: dynamically generates the pipeline

parent 746ab4bdf4c3
No related branches found
No related tags found
1 merge request!1ci: dynamically generates the pipeline
Pipeline #87974 passed
stages:
- setup
- triggers
...@@ -1,17 +4,5 @@ ...@@ -1,17 +4,5 @@
build_buster-slim-pg11: generate-config:
image: stage: setup
name: gcr.io/kaniko-project/executor:debug image: python
entrypoint: [""]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor
--context $CI_PROJECT_DIR/library/buster-slim-pg11
--dockerfile $CI_PROJECT_DIR/library/buster-slim-pg11/Dockerfile
--destination $CI_REGISTRY_IMAGE/buster-slim-pg11
build_kubectl-kustomize:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script: script:
...@@ -17,7 +8,6 @@ ...@@ -17,7 +8,6 @@
script: script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - python3 ./generate_gitlabci.py
- /kaniko/executor artifacts:
--context $CI_PROJECT_DIR/library/kubectl-kustomize paths:
--dockerfile $CI_PROJECT_DIR/library/kubectl-kustomize/Dockerfile - gitlab-ci-generated.yml
--destination $CI_REGISTRY_IMAGE/kubectl-kustomize
...@@ -23,22 +13,7 @@ ...@@ -23,22 +13,7 @@
build_kubectl: trigger-build:
image: stage: triggers
name: gcr.io/kaniko-project/executor:debug trigger:
entrypoint: [""] include:
script: - artifact: gitlab-ci-generated.yml
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json job: generate-config
- /kaniko/executor
--context $CI_PROJECT_DIR/library/kubectl
--dockerfile $CI_PROJECT_DIR/library/kubectl/Dockerfile
--destination $CI_REGISTRY_IMAGE/kubectl
build_python-logilab:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor
--context $CI_PROJECT_DIR/library/python-logilab
--dockerfile $CI_PROJECT_DIR/library/python-logilab/Dockerfile
--destination $CI_REGISTRY_IMAGE/python-logilab
import os
import glob import glob
import sys import sys
...@@ -14,16 +15,10 @@ ...@@ -14,16 +15,10 @@
--destination $CI_REGISTRY_IMAGE/{project} --destination $CI_REGISTRY_IMAGE/{project}
''' '''
try: with open('gitlab-ci-generated.yml', 'w') as f:
if sys.argv[1]:
TEMPLATE += f" --build-arg {sys.argv[1]}={sys.argv[2]}"
except IndexError:
pass
with open('.gitlab-ci.yml', 'w') as f:
for filepath in sorted(glob.glob('library/**/Dockerfile', recursive=True)): for filepath in sorted(glob.glob('library/**/Dockerfile', recursive=True)):
project = '-'.join(filepath.split('/')[1:-1]) project = '-'.join(filepath.split('/')[1:-1])
context = filepath.replace('/Dockerfile', '') context = filepath.replace('/Dockerfile', '')
f.write(TEMPLATE.format(project=project, f.write(TEMPLATE.format(project=project,
context=context, context=context,
filepath=filepath)) filepath=filepath))
...@@ -24,7 +19,6 @@ ...@@ -24,7 +19,6 @@
for filepath in sorted(glob.glob('library/**/Dockerfile', recursive=True)): for filepath in sorted(glob.glob('library/**/Dockerfile', recursive=True)):
project = '-'.join(filepath.split('/')[1:-1]) project = '-'.join(filepath.split('/')[1:-1])
context = filepath.replace('/Dockerfile', '') context = filepath.replace('/Dockerfile', '')
f.write(TEMPLATE.format(project=project, f.write(TEMPLATE.format(project=project,
context=context, context=context,
filepath=filepath)) filepath=filepath))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment