mirror of
https://github.com/kasmtech/workspaces-core-images.git
synced 2025-08-09 14:54:57 +02:00
Resolve KASM-5044 "Feature/ templated pipelines"
This commit is contained in:
committed by
Matthew McClaskey
parent
b1c06a853b
commit
9d5747453e
32
ci-scripts/template-gitlab.py
Normal file
32
ci-scripts/template-gitlab.py
Normal file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from jinja2 import Template
|
||||
import yaml
|
||||
import os
|
||||
|
||||
# Determine if this is a feature branch
|
||||
fileLimits = True
|
||||
if os.getenv('SANITIZED_BRANCH').startswith('release') or os.getenv('SANITIZED_BRANCH') == 'develop':
|
||||
fileLimits = False
|
||||
if os.getenv('CI_PIPELINE_SOURCE') == 'schedule':
|
||||
fileLimits = False
|
||||
|
||||
# Read yaml file with variables
|
||||
with open("template-vars.yaml", 'r') as stream:
|
||||
templateVars = yaml.safe_load(stream)
|
||||
templateVars['KASM_RELEASE'] = os.getenv('KASM_RELEASE')
|
||||
templateVars['TEST_INSTALLER'] = os.getenv('TEST_INSTALLER')
|
||||
templateVars['SANITIZED_BRANCH'] = os.getenv('SANITIZED_BRANCH')
|
||||
templateVars['FILE_LIMITS'] = fileLimits
|
||||
|
||||
# Read template file
|
||||
with open("gitlab-ci.template", 'r') as stream:
|
||||
template = stream.read()
|
||||
|
||||
# Template the variables in
|
||||
jinjaTemplate = Template(template)
|
||||
gitlabCi = jinjaTemplate.render(templateVars)
|
||||
|
||||
# Write out the gitlab file
|
||||
with open('../gitlab-ci.yml', 'w') as out:
|
||||
out.write(gitlabCi + '\n')
|
Reference in New Issue
Block a user