Last active
May 5, 2023 13:22
-
-
Save imoutsatsos/c44b4ac14d074f665cb64ce116d637fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Generated by ChatGPT | |
import jenkins.model.* | |
import hudson.model.* | |
import hudson.XmlFile | |
def jobName = "my-job" | |
def configFilePath = "/path/to/config.xml" | |
def jenkins = Jenkins.getInstance() | |
def configFile = new XmlFile(new File(configFilePath)) | |
if (jenkins.getItem(jobName) != null) { | |
println "Job '${jobName}' already exists." | |
} else { | |
def job = jenkins.createProjectFromXML(jobName, configFile) | |
job.save() | |
println "Job '${jobName}' created." | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment