Skip to content

Instantly share code, notes, and snippets.

@KondaReddyR
Created April 22, 2019 12:26
Show Gist options
  • Save KondaReddyR/d2494534fd95a62427113acd508117de to your computer and use it in GitHub Desktop.
Save KondaReddyR/d2494534fd95a62427113acd508117de to your computer and use it in GitHub Desktop.
Groovy Script to create Pipeline jobs
import jenkins.model.Jenkins
import org.jenkinsci.plugins.workflow.job.WorkflowJob
import org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition
import hudson.plugins.git.GitSCM
WorkflowJob job = Jenkins.instance.createProject(WorkflowJob, 'KondaReddyR/java-project')
def definition = new CpsScmFlowDefinition(new GitSCM('[email protected]:KondaReddyR/java-project.git'), 'resources/housekeeping/install_python_packages.groovy')
definition.scm.userRemoteConfigs[0].credentialsId = 'GITHUB_SSH_KEY'
job.definition = definition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment