Skip to content

Instantly share code, notes, and snippets.

@Kumar-Govind1998
Kumar-Govind1998 / jenkins-create-job-scm-flow.groovy
Created February 17, 2022 07:46 — forked from ivan-pinatti/jenkins-create-job-scm-flow.groovy
Jenkins - Create a Jenkins job via groovy script that; cleans before checkout, shallow clone, sparse checkout only the Jenkinsfile and set lightweight - #jenkins #groovy #jenkins-job #jenkins-git #git #jenkinsfile
#!groovy
// imports
import hudson.plugins.git.*
import hudson.plugins.git.extensions.*
import hudson.plugins.git.extensions.impl.*
import jenkins.model.Jenkins
// parameters
def jobParameters = [
reference: https://souravatta.medium.com/create-jenkins-seedjob-using-job-dsl-script-ac337afd9986
https://stackoverflow.com/questions/35898020/job-dsl-to-create-pipeline-type-job#:~:text=First%20you%20need%20to%20install,script%20and%20provide%20following%20script.&text=Or%20you%20can%20create%20your,located%20in%20remote%20git%20repository.
https://plugins.jenkins.io/job-dsl/
Install <"Job-DSL"> Plugin from Manage Plugin in Jenkins
-------------------------------------------------------------
create a Free-Style Job
=========================================================