Skip to content
Snippets Groups Projects
Commit ec6a0998 authored by Sergio Gonzalez Diaz's avatar Sergio Gonzalez Diaz
Browse files

Update gitlab-ci.yml_generator.py

parent 2fc71559
No related branches found
No related tags found
1 merge request!54Release 2.0.0
......@@ -116,7 +116,7 @@ test {microservice} pytest:
reports:
junit: src/$IMAGE_NAME/tests/report.xml
# Deployment of the {microservice} service in Kubernetes Cluster
# Deployment of the {microservice} service in development Kubernetes Cluster
deploy {microservice} development:
variables:
IMAGE_NAME: '{microservice}' # name of the microservice
......@@ -126,19 +126,57 @@ deploy {microservice} development:
- build {microservice}
- test {microservice} run
script:
- 'sed -i "s/image: .*/image: $CI_REGISTRY\/$CI_PROJECT_NAMESPACE\/$CI_PROJECT_NAME\/$IMAGE_NAME:$IMAGE_TAG/" manifests/$IMAGE_NAME.yaml'
- kubectl version
- kubectl get all
- kubectl apply -f "manifests/$IMAGE_NAME.yaml"
- kubectl get all
# environment:
# name: development
# url: https://example.com
# kubernetes:
# namespace: development
rules:
- changes:
- src/$IMAGE_NAME/*.{py,in,yml}
- src/$IMAGE_NAME/Dockerfile
- src/$IMAGE_NAME/tests/*.py
- src/$IMAGE_NAME/tests/Dockerfile
- manifests/$IMAGE_NAME.yaml
- .gitlab-ci.yml
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"'
when: manual
changes:
- src/$IMAGE_NAME/*.{{py,in,yml}}
- src/$IMAGE_NAME/Dockerfile
- src/$IMAGE_NAME/tests/*.py
- src/$IMAGE_NAME/tests/Dockerfile
- manifests/$IMAGE_NAME.yaml
- .gitlab-ci.yml
# Deployment of the {microservice} service in production Kubernetes Cluster
deploy {microservice} development:
variables:
IMAGE_NAME: '{microservice}' # name of the microservice
IMAGE_TAG: '{tag}' # tag of the container image (production, development, etc)
stage: deploy
needs:
- build {microservice}
- test {microservice} run
script:
- 'sed -i "s/image: .*/image: $CI_REGISTRY\/$CI_PROJECT_NAMESPACE\/$CI_PROJECT_NAME\/$IMAGE_NAME:$IMAGE_TAG/" manifests/$IMAGE_NAME.yaml'
- kubectl version
- kubectl get all
- kubectl apply -f "manifests/$IMAGE_NAME.yaml"
- kubectl get all
# environment:
# name: production
# url: https://example.com
# kubernetes:
# namespace: production
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH'
when: manual
changes:
- src/$IMAGE_NAME/*.{{py,in,yml}}
- src/$IMAGE_NAME/Dockerfile
- src/$IMAGE_NAME/tests/*.py
- src/$IMAGE_NAME/tests/Dockerfile
- manifests/$IMAGE_NAME.yaml
- .gitlab-ci.yml
"""
f.write(yml_template.format(microservice = args.microservice, tag=args.tag))
print("File created in the following path: {file}".format(file=file))
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