本文整理汇总了Java中com.groupon.jenkins.dynamic.build.DynamicBuild类的典型用法代码示例。如果您正苦于以下问题:Java DynamicBuild类的具体用法?Java DynamicBuild怎么用?Java DynamicBuild使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DynamicBuild类属于com.groupon.jenkins.dynamic.build包,在下文中一共展示了DynamicBuild类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notify
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
protected boolean notify(DynamicBuild build, BuildListener listener) {
Map<String, ?> options = (Map<String, ?>) getOptions();
HttpClient client = getHttpClient();
String requestUrl = (String) options.get("url");
PostMethod post = new PostMethod(requestUrl);
Map<String, String> payload = (Map<String, String>) options.get("payload");
ObjectMapper objectMapper = new ObjectMapper();
try {
String payloadJson = objectMapper.writeValueAsString(payload);
StringRequestEntity requestEntity = new StringRequestEntity(payloadJson, "application/json", "UTF-8");
post.setRequestEntity(requestEntity);
int statusCode = client.executeMethod(post);
listener.getLogger().println("Posted Paylod " + payloadJson + " to " + requestUrl + " with response code " + statusCode);
} catch (Exception e) {
listener.getLogger().print("Failed to make a POST to webhook. Check Jenkins logs for exceptions.");
LOGGER.log(Level.WARNING, "Error posting to webhook", e);
return false;
} finally {
post.releaseConnection();
}
return false;
}
示例2: notify
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
public boolean notify(DynamicBuild build, BuildListener listener) {
List rooms = getRooms();
listener.getLogger().println("sending hipchat notifications");
String token = getHipchatConfig().getToken();
for (Object roomId : rooms) {
BuildCause.CommitInfo commitInfo = null;
BuildCause cause = build.getCause(BuildCause.class);
if(cause != null){
commitInfo = cause.getCommitInfo();
}
try {
new SendRoomMessageWithCardRequest(roomId.toString(),token,getColor(build),shouldNotify(build), getNotificationMessage(build,listener),build.getFullUrl(),commitInfo).execute();
} catch (Exception e) {
e.printStackTrace(listener.getLogger());
}
}
return true;
}
示例3: createEmail
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
public MimeMessage createEmail(DynamicBuild build, BuildListener listener) throws AddressException, MessagingException {
List<InternetAddress> to = getToEmailAddress(build, listener);
String from = SetupConfig.get().getFromEmailAddress();
Session session = Session.getDefaultInstance(System.getProperties());
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipients(Message.RecipientType.TO, to.toArray(new InternetAddress[to.size()]));
String subject = getNotificationMessage(build, listener);
message.setSubject(subject);
message.setText("Link to the build " + build.getAbsoluteUrl());
return message;
}
示例4: copyFiles
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
public void copyFiles(final DynamicSubBuild run, final DynamicBuild parent, final String outputFiles, final BuildListener listener) throws IOException {
final String baseWorkSpace;
try {
listener.getLogger().println("Copying files :" + outputFiles);
final FilePath workspacePath = run.getWorkspace();
final FilePath targetPath = parent.getWorkspace();
if (workspacePath != null && targetPath != null) {
baseWorkSpace = workspacePath.toURI().toString();
for (final FilePath file : workspacePath.list(outputFiles)) {
final String dir = file.toURI().toString().replaceAll(baseWorkSpace, "").replaceAll(file.getName(), "");
final FilePath targetChildDir = targetPath.child(dir);
if (!targetChildDir.exists()) {
targetChildDir.mkdirs();
}
file.copyTo(targetChildDir.child(file.getName()));
}
}
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
}
}
示例5: perform
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
public boolean perform(DynamicBuild dynamicBuild, Launcher launcher, BuildListener listener) {
if (!(options instanceof Map)) {
throw new InvalidBuildConfigurationException("Invalid format specified for " + getName() + " . Expecting a Map.");
}
Map<String, Object> jobOptions = (Map<String, Object>) options;
if (shouldKickOffJob(dynamicBuild, jobOptions)) {
String jobName = getJobName(jobOptions);
DynamicProject job = findJob(jobName);
Map<String, String> jobParams = new HashMap<String, String>((Map<String, String>) jobOptions.get(jobName));
jobParams.put("SOURCE_BUILD", getSourceBuildNumber(dynamicBuild));
listener.getLogger().println("Lauching dowstream job :" + job.getFullName());
return job.scheduleBuild(0, getCause(dynamicBuild, job, jobOptions.get(jobName)), getParamsAction(jobParams));
}
return true;
}
示例6: should_group_commit_statueses_by_context
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Test
public void should_group_commit_statueses_by_context() throws IOException {
final CommitHistoryView commitHistoryView = new CommitHistoryView();
final DynamicBuild build = mock(DynamicBuild.class);
final GHRepository githubRepo = mock(GHRepository.class);
when(build.getGithubRepository()).thenReturn(githubRepo);
final PagedIterable<GHCommitStatus> commitStatusesList = mock(PagedIterable.class);
final GHCommitStatus commitStatus1 = mock(GHCommitStatus.class);
final GHCommitStatus commitStatus2 = mock(GHCommitStatus.class);
when(commitStatus1.getContext()).thenReturn("Default");
when(commitStatus2.getContext()).thenReturn("DotCi");
when(commitStatusesList.asList()).thenReturn(Arrays.asList(commitStatus1, commitStatus2));
final GHCommit currentCommit = mock(GHCommit.class);
when(githubRepo.getCommit(null)).thenReturn(currentCommit);
when(currentCommit.listStatuses()).thenReturn(commitStatusesList);
when(githubRepo.getLastCommitStatus(null)).thenReturn(commitStatus1);
commitHistoryView.onLoad(build);
final Map<String, List<GHCommitStatus>> commitStatuses = commitHistoryView.getCommitStatuses();
Assert.assertEquals(commitStatuses.get("Default").get(0), commitStatus1);
Assert.assertEquals(commitStatuses.get("DotCi").get(0), commitStatus2);
}
示例7: getChart
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
public Chart getChart() {
List<DynamicBuild> builds = getCoverageBuilds();
List<String> buildNumbers = new ArrayList<String>();
List<Long> lineCoverages= new ArrayList<Long>();
List<Long> methodsCoverages= new ArrayList<Long>();
List<Long> packagesCoverages= new ArrayList<Long>();
List<Long> filesCoverages= new ArrayList<Long>();
for(DynamicBuild build: builds){
buildNumbers.add(build.getNumber() +"") ;
CoberturaBuildAction coberturaAction = build.getAction(CoberturaBuildAction.class);;
Ratio lineCoverage = coberturaAction.getResult().getCoverage(CoverageMetric.LINE);
lineCoverages.add(new Long(lineCoverage.getPercentage()));
Ratio methodCoverage = coberturaAction.getResult().getCoverage(CoverageMetric.METHOD);
methodsCoverages.add(new Long(methodCoverage.getPercentage()));
Ratio packageCoverage = coberturaAction.getResult().getCoverage(CoverageMetric.PACKAGES);
packagesCoverages.add(new Long(packageCoverage.getPercentage()));
Ratio filesCoverage = coberturaAction.getResult().getCoverage(CoverageMetric.FILES);
filesCoverages.add(new Long(filesCoverage.getPercentage()));
}
return new LineChart(buildNumbers,
Arrays.asList(
new LineChart.DataSet("Line", lineCoverages, ChartColor.BLUE),
new LineChart.DataSet("Method", methodsCoverages, ChartColor.YELLOW),
new LineChart.DataSet("Packages", packagesCoverages,ChartColor.GREEN),
new LineChart.DataSet("Files", filesCoverages, ChartColor.RED)
),
"Build Number","Coverage(%)");
}
示例8: getNotificationMessage
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
protected String getNotificationMessage(DynamicBuild build, BuildListener listener) {
if(getOptions() instanceof Map && ((Map)getOptions()).containsKey("message")){
return (String) ((Map)getOptions()).get("message");
}
return super.getNotificationMessage(build, listener);
}
示例9: perform
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
public boolean perform(DynamicBuild dynamicBuild, Launcher launcher, BuildListener listener) {
/*
* public CheckStylePublisher(final String healthy, final String
* unHealthy, final String thresholdLimit, final String defaultEncoding,
* final boolean useDeltaValues, final String unstableTotalAll, final
* String unstableTotalHigh, final String unstableTotalNormal, final
* String unstableTotalLow, final String unstableNewAll, final String
* unstableNewHigh, final String unstableNewNormal, final String
* unstableNewLow, final String failedTotalAll, final String
* failedTotalHigh, final String failedTotalNormal, final String
* failedTotalLow, final String failedNewAll, final String
* failedNewHigh, final String failedNewNormal, final String
* failedNewLow, final boolean canRunOnFailed, final boolean
* useStableBuildAsReference, final boolean shouldDetectModules, final
* boolean canComputeNew, final String pattern)
*/
CheckStylePublisher publisher = new CheckStylePublisher();
boolean result =false ;
try {
result = publisher.perform(((AbstractBuild) dynamicBuild), launcher, listener);
} catch (Exception e) {
e.printStackTrace(listener.getLogger());
}
return result;
}
示例10: perform
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
public boolean perform(DynamicBuild dynamicBuild, Launcher launcher, BuildListener listener) {
String files = getPluginInputFiles();
listener.getLogger().println(String.format("Archiving JUnit results: '%s'", files));
DescribableList<TestDataPublisher, Descriptor<TestDataPublisher>> testDataPublishers = new DescribableList<TestDataPublisher, Descriptor<TestDataPublisher>>(Saveable.NOOP);
JUnitResultArchiver publisher = new JUnitResultArchiver(files, true, testDataPublishers);
try {
return publisher.perform(((AbstractBuild) dynamicBuild), launcher, listener);
} catch (Exception e) {
listener.getLogger().println(String.format("FAILED archiving JUnit results: %s", e.toString()));
return false;
}
}
示例11: perform
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
public boolean perform(DynamicBuild dynamicBuild, Launcher launcher, BuildListener listener)
{
PmdPublisher publisher = new PmdPublisher();
try {
return publisher.perform(((AbstractBuild<?,?>) dynamicBuild), launcher, listener);
} catch (Exception e) {
e.printStackTrace(listener.getLogger());
return false;
}
}
示例12: perform
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
public boolean perform(DynamicBuild dynamicBuild, Launcher launcher, BuildListener listener)
{
// public JacocoPublisher(
// String execPattern,
// String classPattern,
// String sourcePattern,
// String inclusionPattern,
// String exclusionPattern,
// String maximumInstructionCoverage,
// String maximumBranchCoverage,
// String maximumComplexityCoverage,
// String maximumLineCoverage,
// String maximumMethodCoverage,
// String maximumClassCoverage,
// String minimumInstructionCoverage,
// String minimumBranchCoverage,
// String minimumComplexityCoverage,
// String minimumLineCoverage,
// String minimumMethodCoverage,
// String minimumClassCoverage,
// boolean changeBuildStatus)
JacocoPublisher publisher = new JacocoPublisher(pluginInputFiles, "**/classes", "**/src/main/java",
"", "",
"0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0",
false);
try {
return publisher.perform(((AbstractBuild<?,?>) dynamicBuild), launcher, listener);
} catch (Exception e) {
e.printStackTrace(listener.getLogger());
return false;
}
}
示例13: perform
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
public boolean perform(DynamicBuild dynamicBuild, Launcher launcher, BuildListener listener) {
CoberturaPublisher publisher = new CoberturaPublisher(pluginInputFiles, false, false, false, false, false, false, false, null, 0);
try {
return publisher.perform(((AbstractBuild) dynamicBuild), launcher, listener);
} catch (Exception e) {
e.printStackTrace(listener.getLogger());
return false;
}
}
示例14: perform
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
public boolean perform(DynamicBuild dynamicBuild, Launcher launcher, BuildListener listener) {
TapPublisher publisher = new TapPublisher(pluginInputFiles, true, true, true, true, true, true);
try {
return publisher.perform(((AbstractBuild) dynamicBuild), launcher, listener);
} catch (Exception e) {
return false;
}
}
示例15: perform
import com.groupon.jenkins.dynamic.build.DynamicBuild; //导入依赖的package包/类
@Override
public boolean perform(DynamicBuild build, Launcher launcher, BuildListener listener) {
FindBugsPublisher publisher = new FindBugsPublisher();
try {
return publisher.perform(((AbstractBuild) build), launcher, listener);
} catch (Exception e) {
return false;
}
}