2

I'm trying to setup a Jenkins server with Groovy script:

def repository = 'git@somerepo'
import hudson.tasks.Shell;

job = Jenkins.instance.createProject(FreeStyleProject, 'TestJob')
job.setDescription("Some description")
job.displayName = 'SomeTestJob(TESTING groovy)'

job.scm = new hudson.plugins.git.GitSCM(repository)
job.save()

Now I need to set a repo branch - How do I do this?

migrated from sqa.stackexchange.com Dec 18 '17 at 2:21

This question came from our site for software quality control experts, automation engineers, and software testers.

  • stackoverflow.com/questions/16963309/… – Michael Durrant Dec 18 '17 at 0:00
  • def repository = 'git@somerepo' import hudson.tasks.Shell; job = Jenkins.instance.createProject(FreeStyleProject, 'TestJob') job.setDescription("Some description") job.displayName = 'SomeTestJob(TESTING groovy)' job.scm = new hudson.plugins.git.GitSCM(repository) job.scm.branches = [new BranchSpec('*/master')]; job.save() Thanks a lot Michael Durrant for giving that link ! This is strange - i've seen before but didn't manage to use the answers as i only noticed the jobDsl code fragments that time... – Alter_so Dec 19 '17 at 8:10
  • Please post this as an answer. This Q&A pops up in the unanswered section while is has already been answered. – 030 Mar 11 '18 at 17:49
1
def repository = 'git@somerepo' 
import hudson.tasks.Shell
job = Jenkins.instance.createProject(FreeStyleProject, 'TestJob')
job.setDescription("Some description") 
job.displayName = 'SomeTestJob(TESTING groovy)' 
job.scm = new hudson.plugins.git.GitSCM(repository) 
job.scm.branches = [new BranchSpec('*/master')]
job.save()

Thanks a lot Michael Durrant for giving that link !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.