More Related Content
Similar to Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
Similar to Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~ (20)
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
- 8. 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
- 15. def image = docker.image('nulab-operation-server')
image.inside('-u root') {
sh "fab $target app.release
}
- 19. 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);
}
}
- 20. 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;
}
}
}
- 24. 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() + "/*"));
}