PART 1 - How To Generate Single Stage GitLab Yml File & Execute Job Using PYTHON Script

Publicado em: 01 Março 2024
no canal de: Devops Zplus
655
12

Hello guys You can refer below code.
------------------------------------------------------------------------------------------------------------------------------------------
Step1:- To Create python script e.g create_yml.py

import sys, subprocess

def generate_template(name):
return f"""

stages:
{name}

{name}-job:
stage: {name}
image: ubuntu
script:
echo "Script has been generated by python file"

"""

def create_job(names):
with open("single_pipeline.yml", "w") as f:
for name in names:
f.write(generate_template(name))

if _name_ == "__main__":
names = sys.argv[1].split()
create_job(names)

--------------------------------------------------------------------------------------------------------------------------------------
Step2: To Create .gitlab-ci.yml file

stages:
setup
trigger

setup:
stage: setup
image: python:3
script:
echo "Executing python script"
python3 create_job.py "build"
artifacts:
paths:
single_pipeline.yml

trigger:
stage: trigger
needs:
setup
trigger:
include:
artifact: single_pipeline.yml
job: setup


Nesta página do site você pode assistir ao vídeo on-line PART 1 - How To Generate Single Stage GitLab Yml File & Execute Job Using PYTHON Script duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Devops Zplus 01 Março 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 655 vezes e gostou 12 espectadores. Boa visualização!