• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jreleaser / jreleaser / #477

04 Apr 2025 05:53PM UTC coverage: 35.124% (-5.1%) from 40.183%
#477

push

github

aalmiray
fix(deploy): Add missing Forgejo messages

Related to #1842

18210 of 51845 relevant lines covered (35.12%)

0.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/sdks/jreleaser-ssh-java-sdk/src/main/java/org/jreleaser/sdk/ssh/ScpArtifactDownloader.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 *
4
 * Copyright 2020-2025 The JReleaser authors.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     https://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
package org.jreleaser.sdk.ssh;
19

20
import net.schmizz.sshj.SSHClient;
21
import org.jreleaser.bundle.RB;
22
import org.jreleaser.model.internal.JReleaserContext;
23
import org.jreleaser.model.internal.download.Downloader;
24
import org.jreleaser.model.internal.download.ScpDownloader;
25
import org.jreleaser.model.spi.download.DownloadException;
26
import org.jreleaser.sdk.commons.AbstractArtifactDownloader;
27

28
import java.io.IOException;
29
import java.nio.file.Files;
30
import java.nio.file.Path;
31
import java.nio.file.Paths;
32

33
import static org.jreleaser.sdk.ssh.SshUtils.createSSHClient;
34
import static org.jreleaser.sdk.ssh.SshUtils.disconnect;
35
import static org.jreleaser.util.StringUtils.isBlank;
36

37
/**
38
 * @author Andres Almiray
39
 * @since 1.1.0
40
 */
41
public class ScpArtifactDownloader extends AbstractArtifactDownloader<org.jreleaser.model.api.download.ScpDownloader, ScpDownloader> {
42
    private ScpDownloader downloader;
43

44
    public ScpArtifactDownloader(JReleaserContext context) {
45
        super(context);
×
46
    }
×
47

48
    @Override
49
    public ScpDownloader getDownloader() {
50
        return downloader;
×
51
    }
52

53
    @Override
54
    public void setDownloader(ScpDownloader downloader) {
55
        this.downloader = downloader;
×
56
    }
×
57

58
    @Override
59
    public String getType() {
60
        return org.jreleaser.model.api.download.ScpDownloader.TYPE;
×
61
    }
62

63
    @Override
64
    public void download(String name) throws DownloadException {
65
        SSHClient ssh = createSSHClient(context, downloader);
×
66

67
        try {
68
            for (Downloader.Asset asset : downloader.getAssets()) {
×
69
                downloadAsset(name, ssh, asset);
×
70
            }
×
71
        } finally {
72
            disconnect(downloader, ssh);
×
73
        }
74
    }
×
75

76
    private void downloadAsset(String name, SSHClient ssh, Downloader.Asset asset) throws DownloadException {
77
        String input = asset.getResolvedInput(context, downloader);
×
78
        String output = asset.getResolvedOutput(context, downloader, Paths.get(input).getFileName().toString());
×
79

80
        if (isBlank(output)) {
×
81
            output = Paths.get(input).getFileName().toString();
×
82
        }
83

84
        Path outputPath = context.getDownloadDirectory().resolve(name).resolve(output);
×
85
        context.getLogger().info("{} -> {}", input, context.relativizeToBasedir(outputPath));
×
86

87
        if (!context.isDryrun()) {
×
88
            try {
89
                Files.createDirectories(outputPath.toAbsolutePath().getParent());
×
90
                ssh.newSCPFileTransfer().download(input, outputPath.toAbsolutePath().toString());
×
91
            } catch (IOException e) {
×
92
                throw new DownloadException(RB.$("ERROR_unexpected_download", input), e);
×
93
            }
×
94
        }
95

96
        unpack(asset.getUnpack(), outputPath);
×
97
    }
×
98
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc