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

jreleaser / jreleaser / #475

03 Apr 2025 10:50AM UTC coverage: 40.322% (-8.9%) from 49.193%
#475

push

github

aalmiray
feat(release): Support Forgejo as releaser

Closes #1842

Closes #1843

182 of 1099 new or added lines in 45 files covered. (16.56%)

4239 existing lines in 333 files now uncovered.

20797 of 51577 relevant lines covered (40.32%)

0.4 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/SftpArtifactUploader.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 net.schmizz.sshj.sftp.SFTPClient;
22
import org.jreleaser.bundle.RB;
23
import org.jreleaser.model.internal.JReleaserContext;
24
import org.jreleaser.model.internal.common.Artifact;
25
import org.jreleaser.model.internal.upload.SftpUploader;
26
import org.jreleaser.model.spi.upload.UploadException;
27
import org.jreleaser.sdk.commons.AbstractArtifactUploader;
28

29
import java.io.IOException;
30
import java.nio.file.Path;
31
import java.nio.file.Paths;
32
import java.util.Set;
33

34
import static org.jreleaser.sdk.ssh.SshUtils.close;
35
import static org.jreleaser.sdk.ssh.SshUtils.createDirectories;
36
import static org.jreleaser.sdk.ssh.SshUtils.createSFTPClient;
37
import static org.jreleaser.sdk.ssh.SshUtils.createSSHClient;
38
import static org.jreleaser.sdk.ssh.SshUtils.disconnect;
39

40
/**
41
 * @author Andres Almiray
42
 * @since 1.1.0
43
 */
44
public class SftpArtifactUploader extends AbstractArtifactUploader<org.jreleaser.model.api.upload.SftpUploader, SftpUploader> {
45
    private SftpUploader uploader;
46

47
    public SftpArtifactUploader(JReleaserContext context) {
UNCOV
48
        super(context);
×
UNCOV
49
    }
×
50

51
    @Override
52
    public SftpUploader getUploader() {
UNCOV
53
        return uploader;
×
54
    }
55

56
    @Override
57
    public void setUploader(SftpUploader uploader) {
UNCOV
58
        this.uploader = uploader;
×
UNCOV
59
    }
×
60

61
    @Override
62
    public String getType() {
63
        return org.jreleaser.model.api.upload.SftpUploader.TYPE;
×
64
    }
65

66
    @Override
67
    public void upload(String name) throws UploadException {
UNCOV
68
        Set<Artifact> artifacts = collectArtifacts();
×
UNCOV
69
        if (artifacts.isEmpty()) {
×
70
            context.getLogger().info(RB.$("artifacts.no.match"));
×
71
        }
72

UNCOV
73
        SSHClient ssh = createSSHClient(context, uploader);
×
UNCOV
74
        SFTPClient sftp = createSFTPClient(uploader, ssh);
×
75

76
        try {
UNCOV
77
            for (Artifact artifact : artifacts) {
×
UNCOV
78
                Path path = artifact.getEffectivePath(context);
×
UNCOV
79
                context.getLogger().info(" - {}", path.getFileName());
×
80

UNCOV
81
                if (!context.isDryrun()) {
×
82
                    try {
83
                        String uploadPath = uploader.getResolvedPath(context, artifact);
×
84
                        context.getLogger().debug("   " + RB.$("uploader.uploading.to", uploadPath));
×
85
                        createDirectories(context, uploader, ssh, Paths.get(uploadPath).getParent());
×
86
                        sftp.put(path.toAbsolutePath().toString(), uploadPath);
×
87
                    } catch (IOException e) {
×
88
                        context.getLogger().trace(e);
×
89
                        throw new UploadException(RB.$("ERROR_unexpected_upload",
×
90
                            context.getBasedir().relativize(path)), e);
×
91
                    }
×
92
                }
UNCOV
93
            }
×
94
        } finally {
UNCOV
95
            close(uploader, sftp);
×
UNCOV
96
            disconnect(uploader, ssh);
×
97
        }
UNCOV
98
    }
×
99
}
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