Created
August 21, 2012 14:38
-
-
Save CedricGatay/3416073 to your computer and use it in GitHub Desktop.
Jenkins : quick create job and vm for feature branch
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
import hudson.model.FreeStyleProject | |
import hudson.model.Result | |
import hudson.plugins.copyartifact.CopyArtifact | |
import hudson.plugins.git.BranchSpec | |
import hudson.tasks.BuildTrigger | |
def featureName = "feature" | |
def branchName = "origin/feature/mybranch" | |
def jenkins = jenkins.model.Jenkins.instance | |
FreeStyleProject templateNightly = jenkins.getItem("template-branch"); | |
def jobNightly = jenkins.copy(templateNightly, "branch-"+featureName) | |
jobNightly.disabled = false | |
jobNightly.scm.branches= [new BranchSpec(branchName)] | |
def noSpacefeatureName = featureName.replaceAll(" ", "_"); | |
FreeStyleProject templateVagrant = jenkins.getItem("template-vagrant") | |
def jobVagrant = jenkins.copy(templateVagrant,"vagrant-"+noSpacefeatureName) | |
jobVagrant.disabled = false | |
jobVagrant.builders.find {it instanceof CopyArtifact}.each { CopyArtifact copyArtifact -> | |
copyArtifact.projectName = "branch-"+featureName | |
} | |
jobVagrant.save() | |
jobNightly.getPublishersList().add(new BuildTrigger([jobVagrant], Result.UNSTABLE)); | |
jobNightly.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment