Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 84 additions & 2 deletions app/template_generators/jenkins/jcasc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,86 @@
def jcasc_template_generator(input) -> str:

DSL_Job_Name = 'false' if input.allowsSignup else 'true'
useScriptSecurity = 'true' if input.useScriptSecurity else 'false'
scmCheckoutRetryCount = input.scmCheckoutRetryCount
executators = input.executators

def jcasc_template_generator(input):
prompt = """M"""

prompt = f"""
Generate a Python code, to generate a JCasc file (project name is app/media/MyJcasc)
and install plugins based on the provided list, ensuring a modular, flexible structure to enable users
to configure all essential settings at the first load. Only provide JCasc code, no explanations or
markdown formatting.

Also the file should contain ONLY these sections with following order and do not add emptylines:
- jenkins:
- numExecutors= {executators}
- scmCheckoutRetryCount= {scmCheckoutRetryCount}
- mode : NORMAL
- markupFormatter:
```
rawHtml:
disableSyntaxHighlighting: false
```
- primaryView:
```
all:
name: "all"
```
- crumbIssuer:
standard:
excludeClientIPFromCrumb: true
- credentials:
```
system:
domainCredentials:
- credentials:
- string:
scope: GLOBAL
id: "gitlab-token"
secret: "SECRET KEY"
description: "GitLab personal access token"
```
- unclassified:
```
location:
url: "http://localhost:8080/"
```
- security:
```
globalJobDslSecurityConfiguration:
useScriptSecurity: {useScriptSecurity}
```
- jobs:
``` - script: >
pipelineJob('{DSL_Job_Name}') {{
quietPeriod(0)
properties {{
disableConcurrentBuilds()
}}
logRotator {{
numToKeep(10)
}}
triggers {{
cron("H/15 * * * *")
}}
definition {{
cps {{
script('createJobs()')
}}
}}
}}
```
finally the python code should run without any note that can generate a project folder with the given
schema without
python entry. the final JCasc template must work very well without any error!

import os
project_name = "app/media/MyJcasc"
jcasc_dir = os.path.join(project_name, "jcasc")

# Create project directories
os.makedirs(jcasc_dir, exist_ok=True)

"""
return prompt
Loading