一千萬個為什麽

搜索

從Groovy腳本在Jenkins中創建作業時如何設置Git存儲庫?



我正在嘗試使用Groovy腳本設置Jenkins服務器:

def repository = '[email protected]'
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()

現在我需要設置一個repo分支 - 我該怎麽做?

轉載註明原文: 從Groovy腳本在Jenkins中創建作業時如何設置Git存儲庫?

一共有 1 個回答:

def repository = '[email protected]' 
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()

非常感謝邁克爾杜蘭特給予這個鏈接!