通过我自己的插件,我需要知道 Jenkins slave 的工作区中是否存在一个文件。但是找不到该文件,而它确实存在于从属设备上
artifactsToDeploy = workingDir.act(new FilesDeployerCallable(listener, pairs, artifactoryServer, credentials,
repositoryKey, propertiesToAdd,
artifactoryServer.createProxyConfiguration(Jenkins.getInstance().proxy),configurator.getProductKey(),configurator.getArtifactoryKey(), configurator.getBuildType() ,configurator.getRpmParameters(),build,configurator.issendFcmPayload(), configurator.getModule(), configurator.getTaxonomy()));
}
private static class FilesDeployerCallable implements FilePath.FileCallable<List<Artifact>> {
/**
*
*/
private static final long serialVersionUID = 1L;
private final String repositoryKey;
private BuildListener listener;
private Multimap<String, String> patternPairs;
private ArtifactoryServer server;
private Credentials credentials;
private ArrayListMultimap<String, String> buildProperties;
private ProxyConfiguration proxyConfiguration;
private String artifactKey;
private String buildType;
private String module;
private String taxonomy;
private RpmParameters rpmParameters;
private final AbstractBuild build;
private boolean sendFcmPayload;
private EnvVars env;
public FilesDeployerCallable(BuildListener listener, Multimap<String, String> patternPairs,
ArtifactoryServer server, Credentials credentials, String repositoryKey,
ArrayListMultimap<String, String> buildProperties, ProxyConfiguration proxyConfiguration,String productKey,String artifactKey, String buildType, RpmParameters rpmParameters, AbstractBuild build, boolean sendFcmPayload, String module, String taxonomy) throws IOException, InterruptedException {
this.listener = listener;
this.patternPairs = patternPairs;
this.server = server;
this.credentials = credentials;
this.repositoryKey = repositoryKey;
this.buildProperties = buildProperties;
this.proxyConfiguration = proxyConfiguration;
this.artifactKey = artifactKey;
this.buildType = buildType;
this.module = module;
this.taxonomy = taxonomy;
this.rpmParameters = rpmParameters;
this.build = build;
this.sendFcmPayload = sendFcmPayload;
this.env = build.getEnvironment(listener);
}
java.io.IOException:远程文件操作失败:/jenkins/slaveworkspace/workspace/githubMigration at hudson.remoting.Channel@44434cf3:master-replicated: java.io.IOException: Unable to serialize hudson.FilePath$FileCallableWrapper@2ca3869b at hudson .FilePath.act(FilePath.java:977) 在 dj.pib.productivity.generic.GenericArtifactsDeployer.deploy(GenericArtifactsDeployer.java:148) 在 dj.pib.productivity 的 hudson.FilePath.act(FilePath.java:959)。 generic.ArtifactoryGenericConfigurator$1.tearDown(ArtifactoryGenericConfigurator.java:352) 在 hudson.model.Build$BuildExecution.doRun(Build.java:171) 在 hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:533) 在 hudson.model.Run.execute(Run.java:1759) 在hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:89) at hudson.model.Executor.run(Executor.java:240) 原因:java.io .IOException:无法在 hudson.remoting.UserRequest.(UserRequest.java:63) 在 hudson.remoting.UserRequest.serialize(UserRequest.java:169) 在 hudson.remoting.Channel.call 序列化 hudson.FilePath$FileCallableWrapper@2ca3869b (Channel.java:750) at hudson.FilePath.act(FilePath.java:970) ... 9 更多原因:java.io.NotSerializableException: hudson.model.FreeStyleBuild 在 java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183) 在 java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547) 在 java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508) 在 java.io。 ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream .java:1508) 在 java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431) 在 java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177) 在 java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)在 hudson.remoting.UserRequest。_serialize(UserRequest.java:158) at hudson.remoting.UserRequest.serialize(UserRequest.java:167) ... 12 更多收集元数据...
我究竟做错了什么?
编辑 1:好的,我看到问题是我在 filesDeployerCallable 中传递 AbstractBuild 构建,它不是可序列化的,但我需要它来做我做的事情。它确实给了我一个警告(抽象是原始类型,应该参数化)。我如何参数化它?它在 hudson.model.abstractModel