-
Notifications
You must be signed in to change notification settings - Fork 19
Modernize to Jenkins 2.479 and Jakarta EE 9 #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ mvn.out* | |
.settings/ | ||
.repository/ | ||
.settings.xml | ||
.idea/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.jenkins-ci.plugins</groupId> | ||
<artifactId>plugin</artifactId> | ||
<version>4.86</version> | ||
<relativePath/> | ||
<version>5.6</version> | ||
<relativePath /> | ||
</parent> | ||
|
||
<artifactId>git-server</artifactId> | ||
|
@@ -15,21 +16,6 @@ | |
<name>Jenkins Git server Plugin</name> | ||
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url> | ||
|
||
<properties> | ||
<changelist>999999-SNAPSHOT</changelist> | ||
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ --> | ||
<jenkins.baseline>2.440</jenkins.baseline> | ||
<jenkins.version>${jenkins.baseline}.3</jenkins.version> | ||
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo> | ||
</properties> | ||
|
||
<scm> | ||
<connection>scm:git:https://github.com/${gitHubRepo}.git</connection> | ||
<developerConnection>scm:git:[email protected]:${gitHubRepo}.git</developerConnection> | ||
<url>https://github.com/${gitHubRepo}</url> | ||
<tag>${scmTag}</tag> | ||
</scm> | ||
|
||
<licenses> | ||
<license> | ||
<name>The MIT license</name> | ||
|
@@ -38,14 +24,29 @@ | |
</license> | ||
</licenses> | ||
|
||
<scm> | ||
<connection>scm:git:https://github.com/${gitHubRepo}.git</connection> | ||
<developerConnection>scm:git:[email protected]:${gitHubRepo}.git</developerConnection> | ||
<tag>${scmTag}</tag> | ||
<url>https://github.com/${gitHubRepo}</url> | ||
</scm> | ||
|
||
<properties> | ||
<changelist>999999-SNAPSHOT</changelist> | ||
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ --> | ||
<jenkins.baseline>2.479</jenkins.baseline> | ||
<jenkins.version>${jenkins.baseline}.1</jenkins.version> | ||
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.jenkins.tools.bom</groupId> | ||
<artifactId>bom-${jenkins.baseline}.x</artifactId> | ||
<version>3234.v5ca_5154341ef</version> | ||
<scope>import</scope> | ||
<version>4023.va_eeb_b_4e45f07</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
@@ -67,7 +68,7 @@ | |
<dependency> | ||
<groupId>org.eclipse.jgit</groupId> | ||
<artifactId>org.eclipse.jgit.ssh.apache</artifactId> | ||
<version>6.9.0.202403050737-r</version> | ||
<version>7.0.0.202409031743-r</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
package org.jenkinsci.plugins.gitserver; | ||
|
||
import hudson.FilePath; | ||
import hudson.FilePath.FileCallable; | ||
import hudson.remoting.Pipe; | ||
import hudson.remoting.VirtualChannel; | ||
import java.io.BufferedInputStream; | ||
import java.io.BufferedOutputStream; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import jenkins.MasterToSlaveFileCallable; | ||
import org.apache.commons.io.IOUtils; | ||
import org.eclipse.jgit.errors.NotSupportedException; | ||
|
@@ -20,12 +24,6 @@ | |
import org.eclipse.jgit.transport.URIish; | ||
import org.eclipse.jgit.transport.UploadPack; | ||
|
||
import java.io.BufferedInputStream; | ||
import java.io.BufferedOutputStream; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
|
||
/** | ||
* {@link Transport} implementation across pipes. | ||
* | ||
|
@@ -34,103 +32,104 @@ | |
public class ChannelTransport extends Transport implements PackTransport { | ||
private final FilePath remoteRepository; | ||
|
||
public static Transport open(Repository local, FilePath remoteRepository) throws NotSupportedException, URISyntaxException, TransportException { | ||
if (remoteRepository.isRemote()) | ||
return new ChannelTransport(local,remoteRepository); | ||
else | ||
return Transport.open(local,remoteRepository.getRemote()); | ||
public static Transport open(Repository local, FilePath remoteRepository) | ||
throws NotSupportedException, URISyntaxException, TransportException { | ||
if (remoteRepository.isRemote()) return new ChannelTransport(local, remoteRepository); | ||
else return Transport.open(local, remoteRepository.getRemote()); | ||
} | ||
|
||
public ChannelTransport(Repository local, FilePath remoteRepository) throws URISyntaxException { | ||
super(local, new URIish("channel:"+remoteRepository.getRemote())); | ||
super(local, new URIish("channel:" + remoteRepository.getRemote())); | ||
this.remoteRepository = remoteRepository; | ||
} | ||
|
||
@Override | ||
public FetchConnection openFetch() throws NotSupportedException, TransportException { | ||
final Pipe l2r = Pipe.createLocalToRemote(); | ||
final Pipe r2l = Pipe.createRemoteToLocal(); | ||
|
||
try { | ||
remoteRepository.actAsync(new GitFetchTask(l2r, r2l)); | ||
} catch (IOException e) { | ||
throw new TransportException("Failed to open a fetch connection",e); | ||
throw new TransportException("Failed to open a fetch connection", e); | ||
} catch (InterruptedException e) { | ||
throw new TransportException("Failed to open a fetch connection",e); | ||
Thread.currentThread().interrupt(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not appear to be related to the stated PR goal? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was flagged by the SonarQube for IDE in my IntelliJ IDEA (rule |
||
throw new TransportException("Failed to open a fetch connection", e); | ||
} | ||
|
||
return new BasePackFetchConnection(this) {{ | ||
init(new BufferedInputStream(r2l.getIn()), new BufferedOutputStream(l2r.getOut())); | ||
readAdvertisedRefs(); | ||
}}; | ||
return new BasePackFetchConnection(this) { | ||
{ | ||
init(new BufferedInputStream(r2l.getIn()), new BufferedOutputStream(l2r.getOut())); | ||
readAdvertisedRefs(); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public PushConnection openPush() throws NotSupportedException, TransportException { | ||
final Pipe l2r = Pipe.createLocalToRemote(); | ||
final Pipe r2l = Pipe.createRemoteToLocal(); | ||
|
||
try { | ||
remoteRepository.actAsync(new GitPushTask(l2r, r2l)); | ||
} catch (IOException e) { | ||
throw new TransportException("Failed to open a fetch connection",e); | ||
throw new TransportException("Failed to open a fetch connection", e); | ||
} catch (InterruptedException e) { | ||
throw new TransportException("Failed to open a fetch connection",e); | ||
Thread.currentThread().interrupt(); | ||
throw new TransportException("Failed to open a fetch connection", e); | ||
} | ||
|
||
return new BasePackPushConnection(this) {{ | ||
init(new BufferedInputStream(r2l.getIn()), new BufferedOutputStream(l2r.getOut())); | ||
readAdvertisedRefs(); | ||
}}; | ||
return new BasePackPushConnection(this) { | ||
{ | ||
init(new BufferedInputStream(r2l.getIn()), new BufferedOutputStream(l2r.getOut())); | ||
readAdvertisedRefs(); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
// no-op | ||
} | ||
|
||
private static class GitFetchTask extends MasterToSlaveFileCallable<Void> { | ||
private final Pipe l2r; | ||
private final Pipe r2l; | ||
|
||
public GitFetchTask(Pipe l2r, Pipe r2l) { | ||
this.l2r = l2r; | ||
this.r2l = r2l; | ||
} | ||
|
||
public Void invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { | ||
Repository repo = new FileRepositoryBuilder().setWorkTree(f).build(); | ||
try { | ||
try (Repository repo = new FileRepositoryBuilder().setWorkTree(f).build()) { | ||
final UploadPack rp = new UploadPack(repo); | ||
rp.upload(new BufferedInputStream(l2r.getIn()), new BufferedOutputStream(r2l.getOut()), null); | ||
return null; | ||
} finally { | ||
IOUtils.closeQuietly(l2r.getIn()); | ||
IOUtils.closeQuietly(r2l.getOut()); | ||
repo.close(); | ||
} | ||
} | ||
} | ||
|
||
private static class GitPushTask extends MasterToSlaveFileCallable<Void> { | ||
private final Pipe l2r; | ||
private final Pipe r2l; | ||
|
||
public GitPushTask(Pipe l2r, Pipe r2l) { | ||
this.l2r = l2r; | ||
this.r2l = r2l; | ||
} | ||
|
||
public Void invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { | ||
Repository repo = new FileRepositoryBuilder().setWorkTree(f).build(); | ||
try { | ||
try (Repository repo = new FileRepositoryBuilder().setWorkTree(f).build()) { | ||
final ReceivePack rp = new ReceivePack(repo); | ||
rp.receive(new BufferedInputStream(l2r.getIn()), new BufferedOutputStream(r2l.getOut()), null); | ||
return null; | ||
} finally { | ||
IOUtils.closeQuietly(l2r.getIn()); | ||
IOUtils.closeQuietly(r2l.getOut()); | ||
repo.close(); | ||
} | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.