热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

hudson.model.TaskListener类的使用及代码示例

本文整理了Java中hudson.model.TaskListener类的一些代码示例,展示了TaskListener类的具体用法。这些代码示

本文整理了Java中hudson.model.TaskListener类的一些代码示例,展示了TaskListener类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TaskListener类的具体详情如下:
包路径:hudson.model.TaskListener
类名称:TaskListener

TaskListener介绍

[英]Receives events that happen during some lengthy operation that has some chance of failures, such as a build, SCM change polling, slave launch, and so on.

This interface is implemented by Hudson core and passed to extension points so that they can record the progress of the operation without really knowing how those information and handled/stored by Hudson.

The information is one way or the other made available to users, and so the expectation is that when something goes wrong, enough information shall be written to a TaskListener so that the user can diagnose what's going wrong.

StreamTaskListener is the most typical implementation of this interface. All the TaskListener implementations passed to plugins from Hudson core are remotable.
[中]接收在长时间操作期间发生的事件,这些操作可能会失败,例如构建、SCM更改轮询、从机启动等。
该接口由Hudson core实现,并传递给扩展点,以便它们可以记录操作的进度,而不需要真正了解Hudson如何处理/存储这些信息。
这些信息是以某种方式提供给用户的,因此人们期望,当出现问题时,应向TaskListener写入足够的信息,以便用户能够诊断出问题所在。
StreamTaskListener是该接口最典型的实现。所有从Hudson core传递给插件的TaskListener实现都是远程的。

代码示例

代码示例来源:origin: jenkinsci/jenkins

public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException {
FilePath expected = preferredLocation(tool, node);
Installable inst = getInstallable();
if(inst==null) {
log.getLogger().println("Invalid tool ID "+id);
return expected;
}
if (inst instanceof NodeSpecific) {
inst = (Installable) ((NodeSpecific) inst).forNode(node, log);
}
if(isUpToDate(expected,inst))
return expected;
if(expected.installIfNecessaryFrom(new URL(inst.url), log, "Unpacking " + inst.url + " to " + expected + " on " + node.getDisplayName())) {
expected.child(".timestamp").delete(); // we don't use the timestamp
FilePath base = findPullUpDirectory(expected);
if(base!=null && base!=expected)
base.moveAllChildrenTo(expected);
// leave a record for the next up-to-date check
expected.child(".installedFrom").write(inst.url,"UTF-8");
expected.act(new ZipExtractionInstaller.ChmodRecAPlusX());
}
return expected;
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public void perform(Run build, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException {
try {
listener.getLogger().println(Messages.Fingerprinter_Recording());
Map record = new HashMap();

EnvVars envirOnment= build.getEnvironment(listener);
if(targets.length()!=0) {
String expandedTargets = environment.expand(targets);
record(build, workspace, listener, record, expandedTargets);
}
FingerprintAction fingerprintAction = build.getAction(FingerprintAction.class);
if (fingerprintAction != null) {
fingerprintAction.add(record);
} else {
build.addAction(new FingerprintAction(build,record));
}
if (enableFingerprintsInDependencyGraph) {
Jenkins.getInstance().rebuildDependencyGraphAsync();
}
} catch (IOException e) {
Functions.printStackTrace(e, listener.error(Messages.Fingerprinter_Failed()));
build.setResult(Result.FAILURE);
}
// failing to record fingerprints is an error but not fatal
}

代码示例来源:origin: jenkinsci/jenkins

@Override public PrintWriter fatalError(String msg) {
return delegate.fatalError(msg);
}

代码示例来源:origin: jenkinsci/jenkins

/**
* Places a {@link HyperlinkNote} on the given text.
*
* @param url
* If this starts with '/', it's interpreted as a path within the context path.
*/
default void hyperlink(String url, String text) throws IOException {
annotate(new HyperlinkNote(url, text.length()));
getLogger().print(text);
}

代码示例来源:origin: jenkinsci/jenkins

@Override
protected void fix(TaskListener listener) throws Exception {
LOGGER.info("Initiating a re-keying of secrets. See "+getLogFile());
SecretRewriter rewriter = new SecretRewriter();
try {
PrintStream log = listener.getLogger();
log.println("Started re-keying " + new Date());
int count = rewriter.rewriteRecursive(Jenkins.getInstance().getRootDir(), listener);
log.printf("Completed re-keying %d files on %s\n",count,new Date());
new RekeySecretAdminMonitor().done.on();
LOGGER.info("Secret re-keying completed");
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Fatal failure in re-keying secrets",e);
Functions.printStackTrace(e, listener.error("Fatal failure in rewriting secrets"));
}
}

代码示例来源:origin: jenkinsci/jenkins

listener.getLogger().println("Checking " + item.getFullDisplayName());
for (Node node : nodes) {
FilePath ws = node.getWorkspaceFor(item);
if (ws == null) {
continue; // offline, fine
check = shouldBeDeleted(item, ws, node);
} catch (IOException x) {
Functions.printStackTrace(x, listener.error("Failed to check " + node.getDisplayName()));
continue;
} catch (InterruptedException x) {
Functions.printStackTrace(x, listener.error("Failed to check " + node.getDisplayName()));
continue;
listener.getLogger().println("Deleting " + ws + " on " + node.getDisplayName());
try {
ws.deleteRecursive();
WorkspaceList.tempDir(ws).deleteRecursive();
} catch (IOException x) {
Functions.printStackTrace(x, listener.error("Failed to delete " + ws + " on " + node.getDisplayName()));
} catch (InterruptedException x) {
Functions.printStackTrace(x, listener.error("Failed to delete " + ws + " on " + node.getDisplayName()));

代码示例来源:origin: org.jenkins-ci.plugins/javadoc

@Override public void perform(Run build, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException {
listener.getLogger().println(Messages.JavadocArchiver_Publishing());
EnvVars env = build.getEnvironment(listener);

FilePath javadoc = workspace.child(env.expand(javadocDir));
FilePath target = new FilePath(keepAll ? getJavadocDir(build) : getJavadocDir(build.getParent()));
try {
if (javadoc.copyRecursiveTo("**/*",target)==0) {
if(build.getResult().isBetterOrEqualTo(Result.UNSTABLE)) {
// If the build failed, don't complain that there was no javadoc.
// The build probably didn't even get to the point where it produces javadoc.
listener.error(Messages.JavadocArchiver_NoMatchFound(javadoc,javadoc.validateAntFileMask("**/*")));
}
build.setResult(Result.FAILURE);
return;
}
} catch (IOException e) {
Util.displayIOException(e,listener);
e.printStackTrace(listener.fatalError(Messages.JavadocArchiver_UnableToCopy(javadoc,target)));
build.setResult(Result.FAILURE);
return;
}

build.addAction(new JavadocBuildAction());
}

代码示例来源:origin: jenkinsci/jenkins

private boolean installIfNecessaryFrom(@Nonnull URL archive, @CheckForNull TaskListener listener, @Nonnull String message, int maxRedirects) throws InterruptedException, IOException {
try {
FilePath timestamp = this.child(".timestamp");
long lastModified = timestamp.lastModified();
URLConnection con;
try {
if (this.exists()) {
listener.getLogger().println("Skipping installation of " + archive + " to " + remote + ": " + x);
listener.getLogger().println("Following redirect " + archive.toExternalForm() + " -> " + location);
return installIfNecessaryFrom(getUrlFactory().newURL(location), listener, message, maxRedirects - 1);
} else {
listener.getLogger().println("Skipping installation of " + archive + " to " + remote + " due to too many redirects.");
return false;
return false;
} else if (responseCode != HttpURLConnection.HTTP_OK) {
listener.getLogger().println("Skipping installation of " + archive + " to " + remote + " due to server error: " + responseCode + " " + httpCon.getResponseMessage());
return false;
listener.getLogger().println(message);
if (isRemote()) {
} catch (IOException x) {
if (listener != null) {
Functions.printStackTrace(x, listener.error("Failed to download " + archive + " from agent; will retry from master"));

代码示例来源:origin: jenkinsci/docker-slaves-plugin

@Override
public void pullImage(TaskListener listener, String image) throws IOException, InterruptedException {
ArgumentListBuilder args = new ArgumentListBuilder()
.add("pull")
.add(image);
Launcher launcher = new Launcher.LocalLauncher(listener);
int status = launchDockerCLI(launcher, args)
.stdout(launcher.getListener().getLogger()).join();
if (status != 0) {
throw new IOException("Failed to pull image " + image);
}
}

代码示例来源:origin: jenkinsci/jenkins

private boolean shouldTrigger(Run upstreamBuild, TaskListener listener) {
Jenkins jenkins = Jenkins.getInstance();
if (job == null) {
return false;
downstreamVisible = jenkins.getItemByFullName(job.getFullName()) == job;
} catch (AccessDeniedException ex) {
Authentication originalAuth = Jenkins.getAuthentication();
Job upstream = upstreamBuild.getParent();
Authentication auth = Tasks.getAuthenticationOf((Queue.Task) job);
Item authUpstream = null;
try {
authUpstream = jenkins.getItemByFullName(upstream.getFullName());
if (downstreamVisible) {
listener.getLogger().println(Messages.ReverseBuildTrigger_running_as_cannot_even_see_for_trigger_f(auth.getName(),
upstream.getFullName(), job.getFullName()));
} else {
LOGGER.log(Level.WARNING, "Running as {0} cannot even {1} {2} for trigger from {3}, (but cannot tell {4} that)",
Result result = upstreamBuild.getResult();
return result != null && result.isBetterOrEqualTo(threshold);

代码示例来源:origin: io.jenkins.plugins/docker-slaves

Jenkins j = Jenkins.getInstance();
if (j != null) {
COMPUTERS: for (Computer c : j.getComputers()) {
for (Executor e : c.getExecutors()) {
Queue.Executable exec = e.getCurrentExecutable();
listener.getLogger().println("Queue item for node block in " + run.getFullDisplayName() + " is missing (perhaps JENKINS-34281), but cannot reschedule");
return;
listener.getLogger().println("Queue item for node block in " + run.getFullDisplayName() + " is missing (perhaps JENKINS-34281); rescheduling");
try {
start();

代码示例来源:origin: org.jenkins-ci.plugins/git

@Override
protected void perform(final TaskListener listener) throws Exception {
final EnvVars envirOnment= getRun().getEnvironment(listener);
final FilePath workspace = new FilePath(new File(ws));
final GitClient git = Git.with(listener, environment)
.in(workspace)
.getClient();
for (Map.Entry entry : tagSet.entrySet()) {
try {
String buildNum = "jenkins-"
+ getRun().getParent().getName().replace(" ", "_")
+ "-" + entry.getValue();
git.tag(entry.getValue(), "Jenkins Build #" + buildNum);
for (Map.Entry e : tagSet.entrySet())
GitTagAction.this.tags.get(e.getKey()).add(e.getValue());
getRun().save();
workerThread = null;
}
catch (GitException ex) {
ex.printStackTrace(listener.error("Error tagging repo '%s' : %s", entry.getKey(), ex.getMessage()));
// Failed. Try the next one
listener.getLogger().println("Trying next branch");
}
}
}
}

代码示例来源:origin: jenkinsci/docker-custom-build-environment-plugin

@Override
public String prepareDockerImage(Docker docker, AbstractBuild build, TaskListener listener, boolean forcePull, boolean noCache) throws IOException, InterruptedException {
String expandedCOntextPath= build.getEnvironment(listener).expand(contextPath);
FilePath filePath = build.getWorkspace().child(expandedContextPath);
FilePath dockerFile = filePath.child(getDockerfile());
if (!dockerFile.exists()) {
listener.getLogger().println("Your project is missing a Dockerfile");
throw new InterruptedException("Your project is missing a Dockerfile");
}
listener.getLogger().println("Build Docker image from " + expandedContextPath + "/"+getDockerfile()+" ...");
return docker.buildImage(filePath, dockerFile.getRemote(), forcePull, noCache);
}

代码示例来源:origin: jenkinsci/jenkins

Result result = build.getResult();
if (onlyIfSuccessful && result != null && result.isWorseThan(Result.UNSTABLE)) {
listener.getLogger().println(Messages.ArtifactArchiver_SkipBecauseOnlyIfSuccessful());
return;
listener.getLogger().println(Messages.ArtifactArchiver_ARCHIVING_ARTIFACTS());
try {
String artifacts = build.getEnvironment(listener).expand(this.artifacts);
Map files = ws.act(new ListFiles(artifacts, excludes, defaultExcludes, caseSensitive));
if (!files.isEmpty()) {
build.pickArtifactManager().archive(ws, launcher, BuildListenerAdapter.wrap(listener), files);
if (fingerprint) {
new Fingerprinter(artifacts).perform(build, ws, launcher, listener);
if (result == null || result.isBetterOrEqualTo(Result.UNSTABLE)) {
try {
String msg = ws.validateAntFileMask(artifacts, FilePath.VALIDATE_ANT_FILE_MASK_BOUND, caseSensitive);
if (msg != null) {
listener.getLogger().println(msg);
Functions.printStackTrace(e, listener.getLogger());
listener.getLogger().println(Messages.ArtifactArchiver_NoMatchFound(artifacts));
} else {
throw new AbortException(Messages.ArtifactArchiver_NoMatchFound(artifacts));

代码示例来源:origin: jenkinsci/artifactory-plugin

@Override
protected Boolean run() throws Exception {
ArgumentListBuilder args = new ArgumentListBuilder();
org.jfrog.hudson.ArtifactoryServer artifactoryServer = Utils.prepareArtifactoryServer(null, step.getServer());
ArtifactoryConfigurator cOnfigurator= new ArtifactoryConfigurator(artifactoryServer);
CredentialsConfig deployerCOnfig= CredentialManager.getPreferredDeployer(configurator, artifactoryServer);
String username = deployerConfig.provideUsername(build.getParent());
String serverName = step.getServerName();
args.addTokenized("conan user");
args.add(username);
args.add("-p");
args.addMasked(deployerConfig.providePassword(build.getParent()));
args.add("-r");
args.add(serverName);
EnvVars extendedEnv = new EnvVars(env);
extendedEnv.put(Utils.CONAN_USER_HOME, step.getConanHome());
listener.getLogger().println("Adding conan user '" + username + "', server '" + serverName + "'");
Utils.exeConan(args, ws, launcher, listener, build, extendedEnv);
return true;
}
}

代码示例来源:origin: jenkinsci/artifactory-plugin

private ArgumentListBuilder getGradleExecutor() {
ArgumentListBuilder args = new ArgumentListBuilder();
if (gradleBuild.isUseWrapper()) {
String execName = launcher.isUnix() ? GradleInstallation.UNIX_GRADLE_WRAPPER_COMMAND : GradleInstallation.WINDOWS_GRADLE_WRAPPER_COMMAND;
FilePath gradleWrapperFile = new FilePath(new FilePath(ws, rootDir), execName);
args.add(gradleWrapperFile.getRemote());
} else {
try {
args.add(getGradleExe());
} catch (Exception e) {
listener.error("Couldn't find Gradle executable.");
build.setResult(Result.FAILURE);
throw new Run.RunnerAbortedException();
}
}
args.addTokenized(getSwitches()).
addTokenized(tasks).
add("-b", getBuildFileFullPath());
if (!launcher.isUnix()) {
args = args.toWindowsCommand();
}
return args;
}

代码示例来源:origin: jenkinsci/jenkins

public String getToolHome(Node node, ToolInstallation tool, TaskListener log) throws IOException, InterruptedException {
if (node.getRootPath() == null) {
log.error(node.getDisplayName() + " is offline; cannot locate " + tool.getName());
return null;
return installer.performInstallation(tool, node, log).getRemote();
} finally {
semaphore.release();
installer.getDescriptor().getDisplayName(),
tool.getName(),
node.getDisplayName()));
log.getLogger().println(message);

代码示例来源:origin: jenkinsci/jenkins

/**
* Sends the stdout to the given {@link TaskListener}.
*
* @param out Task listener (must be safely remotable)
* @return {@code this}
*/
public ProcStarter stdout(@Nonnull TaskListener out) {
stdout = out.getLogger();
stdoutListener = out;
return this;
}

代码示例来源:origin: jenkinsci/subversion-plugin

private void assertRevision(@CheckForNull SCMRevision rev, @CheckForNull String expectedFile, @NonNull SCMSource source, @NonNull Run run, @NonNull TaskListener listener) throws Exception {
if (rev == null) {
assertNull(expectedFile);
return;
}
FilePath ws = new FilePath(run.getRootDir()).child("tmp");
try {
source.build(rev.getHead(), rev).checkout(run, new Launcher.LocalLauncher(listener), ws, listener, null, SCMRevisionState.NONE);
} catch (Exception x) {
x.printStackTrace(listener.error("could not check out"));
assertNull(expectedFile);
return;
}
FilePath file = ws.child("file");
assertEquals(expectedFile, file.exists() ? file.readToString() : null);
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public boolean shouldTriggerBuild(AbstractBuild build, TaskListener listener,
List actions) {
AbstractProject downstream = getDownstreamProject();
if (Jenkins.getInstance().getItemByFullName(downstream.getFullName()) != downstream) { // this checks Item.READ also on parent folders
LOGGER.log(Level.WARNING, "Running as {0} cannot even see {1} for trigger from {2}", new Object[] {Jenkins.getAuthentication().getName(), downstream, getUpstreamProject()});
return false; // do not even issue a warning to build log
}
if (!downstream.hasPermission(Item.BUILD)) {
listener.getLogger().println(Messages.BuildTrigger_you_have_no_permission_to_build_(ModelHyperlinkNote.encodeTo(downstream)));
return false;
}
return build.getResult().isBetterOrEqualTo(threshold);
}
});

推荐阅读
  • 如果应用程序经常播放密集、急促而又短暂的音效(如游戏音效)那么使用MediaPlayer显得有些不太适合了。因为MediaPlayer存在如下缺点:1)延时时间较长,且资源占用率高 ... [详细]
  • 在对WordPress Duplicator插件0.4.4版本的安全评估中,发现其存在跨站脚本(XSS)攻击漏洞。此漏洞可能被利用进行恶意操作,建议用户及时更新至最新版本以确保系统安全。测试方法仅限于安全研究和教学目的,使用时需自行承担风险。漏洞编号:HTB23162。 ... [详细]
  • 在Android平台中,播放音频的采样率通常固定为44.1kHz,而录音的采样率则固定为8kHz。为了确保音频设备的正常工作,底层驱动必须预先设定这些固定的采样率。当上层应用提供的采样率与这些预设值不匹配时,需要通过重采样(resample)技术来调整采样率,以保证音频数据的正确处理和传输。本文将详细探讨FFMpeg在音频处理中的基础理论及重采样技术的应用。 ... [详细]
  • 在Linux系统中,网络配置是至关重要的任务之一。本文详细解析了Firewalld和Netfilter机制,并探讨了iptables的应用。通过使用`ip addr show`命令来查看网卡IP地址(需要安装`iproute`包),当网卡未分配IP地址或处于关闭状态时,可以通过`ip link set`命令进行配置和激活。此外,文章还介绍了如何利用Firewalld和iptables实现网络流量控制和安全策略管理,为系统管理员提供了实用的操作指南。 ... [详细]
  • 数字图书馆近期展出了一批精选的Linux经典著作,这些书籍虽然部分较为陈旧,但依然具有重要的参考价值。如需转载相关内容,请务必注明来源:小文论坛(http://www.xiaowenbbs.com)。 ... [详细]
  • 本文介绍了如何使用Flume从Linux文件系统收集日志并存储到HDFS,然后通过MapReduce清洗数据,使用Hive进行数据分析,并最终通过Sqoop将结果导出到MySQL数据库。 ... [详细]
  • 本文详细介绍了 Pentaho Kettle 中 RowMetaInterface.writeMeta 方法的使用,并提供了多个代码示例,帮助开发者更好地理解和应用该方法。 ... [详细]
  • 本文详细介绍了Java反射机制的基本概念、获取Class对象的方法、反射的主要功能及其在实际开发中的应用。通过具体示例,帮助读者更好地理解和使用Java反射。 ... [详细]
  • 基于iSCSI的SQL Server 2012群集测试(一)SQL群集安装
    一、测试需求介绍与准备公司计划服务器迁移过程计划同时上线SQLServer2012,引入SQLServer2012群集提高高可用性,需要对SQLServ ... [详细]
  • 本文详细介绍了 PHP 中对象的生命周期、内存管理和魔术方法的使用,包括对象的自动销毁、析构函数的作用以及各种魔术方法的具体应用场景。 ... [详细]
  • 本文介绍了如何利用 `matplotlib` 库中的 `FuncAnimation` 类将 Python 中的动态图像保存为视频文件。通过详细解释 `FuncAnimation` 类的参数和方法,文章提供了多种实用技巧,帮助用户高效地生成高质量的动态图像视频。此外,还探讨了不同视频编码器的选择及其对输出文件质量的影响,为读者提供了全面的技术指导。 ... [详细]
  • 本文详细介绍了 InfluxDB、collectd 和 Grafana 的安装与配置流程。首先,按照启动顺序依次安装并配置 InfluxDB、collectd 和 Grafana。InfluxDB 作为时序数据库,用于存储时间序列数据;collectd 负责数据的采集与传输;Grafana 则用于数据的可视化展示。文中提供了 collectd 的官方文档链接,便于用户参考和进一步了解其配置选项。通过本指南,读者可以轻松搭建一个高效的数据监控系统。 ... [详细]
  • Python错误重试让多少开发者头疼?高效解决方案出炉
    ### 优化后的摘要在处理 Python 开发中的错误重试问题时,许多开发者常常感到困扰。为了应对这一挑战,`tenacity` 库提供了一种高效的解决方案。首先,通过 `pip install tenacity` 安装该库。使用时,可以通过简单的规则配置重试策略。例如,可以设置多个重试条件,使用 `|`(或)和 `&`(与)操作符组合不同的参数,从而实现灵活的错误重试机制。此外,`tenacity` 还支持自定义等待时间、重试次数和异常处理,为开发者提供了强大的工具来提高代码的健壮性和可靠性。 ... [详细]
  • 本文探讨了在使用 Outlook 时遇到的一个常见问题:无法加载 SAVCORP90 插件,导致软件功能受限。该问题通常表现为在启动 Outlook 时会收到错误提示,影响用户的正常使用体验。文章详细分析了可能的原因,并提供了多种解决方法,包括检查插件兼容性、重新安装插件以及更新 Outlook 版本等。通过这些步骤,用户可以有效解决这一问题,恢复 Outlook 的正常运行。 ... [详细]
  • 本文探讨了如何在C#应用程序中通过选择ComboBox项从MySQL数据库中检索数据值。具体介绍了在事件处理方法 `comboBox2_SelectedIndexChanged` 中可能出现的常见错误,并提供了详细的解决方案和优化建议,以确保数据能够正确且高效地从数据库中读取并显示在界面上。此外,还讨论了连接字符串的配置、SQL查询语句的编写以及异常处理的最佳实践,帮助开发者避免常见的陷阱并提高代码的健壮性。 ... [详细]
author-avatar
筱白
这个世界如果你不努力学习,你就没有生存的机会
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有