Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~

14,119 views

Published on

第9回Jenkins勉強会
http://jenkins.connpass.com/event/35030/

Published in: Technology
  • Be the first to comment

Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~

  1. 1. catchError { def stage def util // node { checkout scm stage = load 'jenkins/stage.groovy' util = load 'jenkins/util.groovy' } // stage.compile(util) if (!stage.test(util)) return stage.pkg(util, 'dev') stage.deploy(util, 'dev') if (!stage.smokeTest(util)) return stage.pkg(util, 'beta') } typetalkSend name: 'Jenkins', topicId: 1234
  2. 2. catchError { stage.compile(util) if (!stage.test(util)) return } typetalkSend name: 'Jenkins', topicId: 1234 def isSuccess() { currentBuild.result == 'SUCCESS' || currentBuild.result == null }
  3. 3. def image = docker.image('nulab-operation-server') image.inside('-u root') { sh "fab $target app.release }
  4. 4. public class TypetalkSendStep extends AbstractStepImpl { @DataBoundConstructor public TypetalkSendStep(@Nonnull String name, @Nonnull Long topicId) { this.name = name; this.topicId = topicId; } @Extension public static class DescriptorImpl extends AbstractStepDescriptorImpl { @Override public String getFunctionName() { return "typetalkSend"; } @Override public String getDisplayName() { return "Notify Typetalk when the build fails"; } public DescriptorImpl() { super(TypetalkSendStepExecution.class); } }
  5. 5. public static class TypetalkSendStepExecution extends AbstractSynchronousNonBlockingStepExecution<Void> { private static final long serialVersionUID = 1L; @Inject transient TypetalkSendStep step; @StepContextParameter transient TaskListener listener; @StepContextParameter transient Run run; @Override protected Void run() throws Exception { new NotifyDelegate(step.name, step.topicId, listener, run) .notifyResult(); return null; } } }
  6. 6. List<RefSpec> refSpecs = getRefSpecs(); client.fetch(remoteName, refSpecs.toArray(new RefSpec[refSpecs.size()])); … for (Branch b : client.getRemoteBranches()) { if (!isPullRequestOpen(pullRequests, branchName)) { continue; } … } protected List<RefSpec> getRefSpecs() { // return Arrays.asList(new RefSpec("+refs/heads/*:refs/remotes/" + getRemoteName() + "/*")); return Arrays.asList(new RefSpec("+refs/pull/*:refs/remotes/" + getRemoteName() + "/*")); }

×