Exemplo n.º 1
0
        private void DownloadFile(JenkinsBuildArtifact artifact)
        {
            var config = (JenkinsConfigurer)this.GetExtensionConfigurer();

            var remoteFileName = PathEx.Combine(this.Context.TargetDirectory, artifact.FileName);
            var fileOps        = this.Context.Agent.GetService <IFileOperationsExecuter>();
            var remote         = this.Context.Agent.TryGetService <IRemoteMethodExecuter>();
            var zip            = this.Context.Agent.GetService <IRemoteZip>();

            if (remote != null)
            {
                this.LogDebug("Downloading to {0}...", remoteFileName);
                remote.InvokeMethod(
                    new Action <JenkinsConfigurer, string, string, string, JenkinsBuildArtifact, ILogger>(DownloadSingleArtifactInternal),
                    (JenkinsConfigurer)this.GetExtensionConfigurer(),
                    this.JobName,
                    this.BuildNumber,
                    remoteFileName,
                    artifact,
                    this
                    );
            }
            else
            {
                var localFileName = Path.GetTempFileName();

                this.LogDebug("Downloading to {0}...", localFileName);
                new JenkinsClient(config, this).DownloadSingleArtifact(this.JobName, this.BuildNumber, localFileName, artifact);

                this.LogDebug("Transferring to server...", remoteFileName);
                using (var localFile = File.OpenRead(localFileName))
                    using (var remoteFile = fileOps.OpenFile(remoteFileName, FileMode.Create, FileAccess.Write))
                    {
                        localFile.CopyTo(remoteFile);
                    }
            }
        }
Exemplo n.º 2
0
        private static void DownloadSingleArtifactInternal(JenkinsConfigurer configurer, string job, string buildNumber, string fileName, JenkinsBuildArtifact artifact, ILogger logger)
        {
            var client = new JenkinsClient(configurer, logger);

            client.DownloadSingleArtifactAsync(job, buildNumber, fileName, artifact).WaitAndUnwrapExceptions();
        }
Exemplo n.º 3
0
 public void DownloadSingleArtifact(string jobName, string buildNumber, string fileName, JenkinsBuildArtifact artifact)
 {
     this.Download(
         "/job/" + Uri.EscapeUriString(jobName) + '/' + Uri.EscapeUriString(buildNumber) + "/artifact/" + artifact.RelativePath,
         fileName);
 }