Commit bb05b4cc authored by Kamlesh Todai's avatar Kamlesh Todai
Browse files

Rename config file names to match the expectation of generate pipeline python...

Rename config file names to match the expectation  of generate pipeline python script. Add python script to generate pipeline and .gitlab-ci.yml to run the CI/CD pipeline
parent fd4c862b
Pipeline #3283 failed with stages
in 7 seconds
workflow:
stages:
- generate
- test
# --------------------------------------------------------------------------------
# Child pipeline generation
generate-pipeline:
image: python
stage: generate
artifacts:
paths:
- '*.gitlab-ci.yml'
script:
- ./generate-pipeline.py
- tail -n 10000 *.gitlab-ci.yml
# --------------------------------------------------------------------------------
# Invoke a child pipeline per environment
aws v2.4:
trigger:
strategy: depend
include:
- artifact: aws.OSDU R3 PROD v2.4.gitlab-ci.yml
job: generate-pipeline
azure v2.4:
trigger:
strategy: depend
include:
- artifact: azure.OSDU R3 PROD v2.4.gitlab-ci.yml
job: generate-pipeline
#gcp v2.4:
# trigger:
# strategy: depend
# include:
# - artifact: gcp.OSDU R3 PROD v2.4.gitlab-ci.yml
# job: generate-pipeline
#ibm v2.4:
# trigger:
# strategy: depend
# include:
# - artifact: ibm.OSDU R3PROD v2.4.gitlab-ci.yml
# job: generate-pipeline
#!/usr/bin/env python3
import os
environments = []
collections = []
i = 0;
for root, dirnames, filenames in os.walk(os.environ['CI_PROJECT_DIR']):
if "Postman Collection" in root:
for f in filenames:
def addEntry(array):
array.append({
'nameParts': os.path.basename(f).split('.')[0:-2],
'path': os.path.join(root, f)
})
if f.endswith('.postman_environment.json'): addEntry(environments);
if f.endswith('.postman_collection.json'): addEntry(collections);
for environ in environments:
platform = environ['nameParts'][0]
environName = '.'.join(environ['nameParts'])
with open(environName + '.gitlab-ci.yml', 'w') as pipelineConfig:
stageName = platform + ' Test'
pipelineConfig.write('\n'.join([
'stages:',
' - ' + stageName,
'',
'.newman:',
' stage: ' + stageName,
' tags: ' + "[\"docker-runner\"]",
' image:',
' name: postman/newman_alpine33',
' entrypoint: [""]',
' variables:',
' ENVIRONMENT: ' + environ['path'],
' script:',
' - newman --version ',
'# - npm install -g newman-reporter-html',
'# - npm install -g newman-reporter-htmlextra',
'# - newman run "$COLLECTION_JSON" -e "$ENVIRONMENT" -d "$' + platform.upper() + '_TEST_COLLECTION_CONFIG" --reporters cli,htmlextra,junit --reporter-htmlextra-export "$HTML_REPORT_NAME" --reporter-junit-export "$JUNIT_REPORT_NAME"',
' - newman run "$COLLECTION_JSON" -e "$ENVIRONMENT" -d "$' + platform.upper() + '_TEST_COLLECTION_CONFIG" --reporters cli',
'',
'# --------------------------------------------------------------------------------'
]) + '\n')
for collect in collections:
collectionName = '.'.join(collect['nameParts'])
sep = '_';
collString = sep.join(collect['nameParts']);
platformString = platform + ".";
htmlReportName = platformString + collString + "_report_extra.html";
junitReportName = platformString + collString + "_report_junit.xml"
pipelineConfig.write('\n'.join([
'',
collectionName + ':',
' extends: .newman',
' variables:',
' COLLECTION_JSON: "' + collect['path'] + '"',
' HTML_REPORT_NAME: "' + htmlReportName + '"',
' JUNIT_REPORT_NAME: "' + junitReportName + '"'
]) + '\n')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment