Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
964c603
Bump git-changelist-maven-extension from 1.2 to 1.3
dependabot[bot] Jan 3, 2022
bc4dc04
Bump plugin from 4.31 to 4.33 (#267)
dependabot[bot] Jan 21, 2022
36c379a
Create jenkins-security-scan.yml
kuisathaverat Feb 26, 2022
e0fde81
Bump testcontainers from 1.16.2 to 1.16.3 (#268)
dependabot[bot] Feb 26, 2022
ecacc09
Replace assertion and use lambda (#270)
offa Feb 26, 2022
2eb3710
Bump plugin from 4.33 to 4.35 (#272)
dependabot[bot] Feb 26, 2022
f3105af
Update jenkins-security-scan.yml
kuisathaverat Feb 26, 2022
4f02481
feat: enable continouos delivery (#269)
kuisathaverat Mar 1, 2022
726b4e1
Bump actions/checkout from 2.3.4 to 2.4.0 (#276)
dependabot[bot] Mar 1, 2022
f245b0d
Changes monitor category (#274)
alecharp Mar 1, 2022
66beec1
Bump plugin from 4.35 to 4.37 (#275)
dependabot[bot] Mar 1, 2022
ba0d6a2
Bump actions/checkout from 2.4.0 to 3 (#277)
dependabot[bot] Mar 3, 2022
2253ced
chore: change the version number format (#278)
kuisathaverat Mar 5, 2022
80a9538
chore: test most common SSH connections (#279)
kuisathaverat Mar 7, 2022
2d29533
Bump plugin from 4.37 to 4.40 (#282)
dependabot[bot] Apr 8, 2022
1083ce3
chore: update Jenkins Core to 2.319 (#284)
kuisathaverat Apr 8, 2022
fad54aa
Bump actions/setup-java from 2 to 3 (#285)
dependabot[bot] Apr 11, 2022
ab864a8
Bump sshd from 3.1.0 to 3.228.v4c9f9e652c86 (#287)
dependabot[bot] Apr 20, 2022
b9e346e
Bump bom-2.319.x from 1246.va_b_50630c1d19 to 1280.vd669827e38cd (#290)
dependabot[bot] Apr 20, 2022
ffaccaa
Bump testcontainers from 1.16.3 to 1.17.1 (#289)
dependabot[bot] Apr 21, 2022
c82988f
Bump bom-2.319.x from 1280.vd669827e38cd to 1289.v5c4b_1c43511b_ (#291)
dependabot[bot] Apr 25, 2022
dcc8631
Bump bom-2.319.x from 1289.v5c4b_1c43511b_ to 1342.v729ca_3818e88 (#293)
dependabot[bot] Apr 29, 2022
2d13263
Bump jenkins-infra/jenkins-maven-cd-action from 1.2.0 to 1.3.0 (#296)
dependabot[bot] May 9, 2022
796376b
Update information for Windows OpenSSH agents (#294)
slide May 9, 2022
87a762f
Bump jenkins-infra/interesting-category-action from 1.0.0 to 1.1.0 (#…
dependabot[bot] May 10, 2022
1c7698d
Bump sshd from 3.228.v4c9f9e652c86 to 3.236.ved5e1b_cb_50b_2 (#300)
dependabot[bot] May 20, 2022
7faa925
Bump testcontainers from 1.17.1 to 1.17.2
dependabot[bot] May 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
interval: "daily"
- package-ecosystem: "github-actions"
directory: /
schedule:
interval: "daily"
6 changes: 2 additions & 4 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.adoc
# https://www.jenkins.io/doc/developer/publishing/releasing-cd/#release-notes
_extends: .github
# Semantic versioning is used d=for this plugin: https://semver.org/
version-template: $MAJOR.$MINOR.$PATCH
tag-template: ssh-slaves-$NEXT_PATCH_VERSION
name-template: $NEXT_PATCH_VERSION

59 changes: 59 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Note: additional setup is required, see https://www.jenkins.io/redirect/continuous-delivery-of-plugins

name: cd
on:
workflow_dispatch:
check_run:
types:
- completed

jobs:
validate:
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.verify-ci-status.outputs.result == 'success' && steps.interesting-categories.outputs.interesting == 'true' }}
steps:
- name: Verify CI status
uses: jenkins-infra/verify-ci-status-action@v1.2.0
id: verify-ci-status
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
output_result: true

- name: Release Drafter
uses: release-drafter/release-drafter@v5
if: steps.verify-ci-status.outputs.result == 'success'
with:
name: next
tag: next
version: next
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check interesting categories
uses: jenkins-infra/interesting-category-action@v1.1.0
id: interesting-categories
if: steps.verify-ci-status.outputs.result == 'success'
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
runs-on: ubuntu-latest
needs: [validate]
if: needs.validate.outputs.should_release == 'true'
steps:
- name: Check out
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 8
- name: Release
uses: jenkins-infra/jenkins-maven-cd-action@v1.3.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/jenkins-security-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Jenkins Security Scan
on:
push:
branches:
- main
# see https://github.com/jenkins-infra/jenkins-security-scan/issues/3
# pull_request:
# types: [ opened, synchronize, reopened ]
workflow_dispatch:

jobs:
security-scan:
uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v1
with:
java-cache: '' # Optionally enable use of a build dependency cache. Specify 'maven' or 'gradle' as appropriate.
java-version: 11 # What version of Java to set up for the build.
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.2</version>
<version>1.3</version>
</extension>
</extensions>
1 change: 1 addition & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
-Dchangelist.format=%d.v%s
5 changes: 4 additions & 1 deletion doc/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,16 @@ See [SSH Build Agents and Cygwin](https://wiki.jenkins.io/display/JENKINS/SSH+sl

### Launch Windows agents using Microsoft OpenSSH

The current version of the plugin does not run directly on PowerShell, you have to use prefix and suffix settings to trick the command and make it works, Windows 10 machines can run as SSH agents with the Microsoft OpenSSH server by using:
The current version of the plugin does not run when Powershell is the default shell for the agent system. To connect to the agent you have to use prefix and suffix settings to trick the command and make it work, Windows 10/11 machines can run as SSH agents with the Microsoft OpenSSH server by using:

**Prefix Start Agent Command**

```
powershell -Command "cd C:\J\S ; C:\J\S\jdk\bin\java.exe -jar remoting.jar" ; exit 0 ; rem '
```

`C:\J\S` is the path to the agent work directory on the agent system. If java is in a different directory, you will need to specify that directory instead of `C:\J\S\jdk\bin`.

**Suffix Start Agent Command**

```
Expand Down
22 changes: 9 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.31</version>
<version>4.40</version>
</parent>

<artifactId>ssh-slaves</artifactId>
<version>${revision}${changelist}</version>
<version>${revision}.${changelist}</version>
<packaging>hpi</packaging>

<name>SSH Build Agents plugin</name>
Expand All @@ -25,9 +25,9 @@
</licenses>

<properties>
<revision>1.33.1</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.289.1</jenkins.version>
<revision>1</revision>
<changelist>999999-SNAPSHOT</changelist>
<jenkins.version>2.319.1</jenkins.version>
<java.level>8</java.level>
<hpi.compatibleSinceVersion>1.31.0</hpi.compatibleSinceVersion>
</properties>
Expand Down Expand Up @@ -102,19 +102,15 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.277.x</artifactId>
<version>961.vf0c9f6f59827</version>
<artifactId>bom-2.319.x</artifactId>
<version>1342.v729ca_3818e88</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jackson2-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -134,7 +130,7 @@
<dependency>
<groupId>org.jenkins-ci.modules</groupId>
<artifactId>sshd</artifactId>
<version>3.1.0</version>
<version>3.236.ved5e1b_cb_50b_2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -162,7 +158,7 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.16.2</version>
<version>1.17.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
104 changes: 51 additions & 53 deletions src/main/java/hudson/plugins/sshslaves/SSHLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -419,60 +419,58 @@ public void launch(final SlaveComputer computer, final TaskListener listener) th
launcherExecutorService = Executors.newSingleThreadExecutor(
new NamingThreadFactory(Executors.defaultThreadFactory(), "SSHLauncher.launch for '" + computer.getName() + "' node"));
Set<Callable<Boolean>> callables = new HashSet<>();
callables.add(new Callable<Boolean>() {
public Boolean call() throws InterruptedException {
Boolean rval = Boolean.FALSE;
try {
String[] preferredKeyAlgorithms = getSshHostKeyVerificationStrategyDefaulted().getPreferredKeyAlgorithms(computer);
if (preferredKeyAlgorithms != null && preferredKeyAlgorithms.length > 0) { // JENKINS-44832
connection.setServerHostKeyAlgorithms(preferredKeyAlgorithms);
} else {
listener.getLogger().println("Warning: no key algorithms provided; JENKINS-42959 disabled");
}

listener.getLogger().println(logConfiguration());

openConnection(listener, computer);

verifyNoHeaderJunk(listener);
reportEnvironment(listener);

final String workingDirectory = getWorkingDirectory(computer);
if (workingDirectory == null) {
listener.error("Cannot get the working directory for " + computer);
return Boolean.FALSE;
}

String java = null;
if (StringUtils.isNotBlank(javaPath)) {
java = expandExpression(computer, javaPath);
} else {
checkJavaIsInPath(listener);
//FIXME deprecated on 2020-12-10, it will removed after 2021-09-01
JavaVersionChecker javaVersionChecker = new JavaVersionChecker(computer, listener, getJvmOptions(),
connection);
java = javaVersionChecker.resolveJava();
}

copyAgentJar(listener, workingDirectory);

startAgent(computer, listener, java, workingDirectory);

PluginImpl.register(connection);
rval = Boolean.TRUE;
} catch (RuntimeException|Error e) {
String msg = Messages.SSHLauncher_UnexpectedError();
if(StringUtils.isNotBlank(e.getMessage())){
msg = e.getMessage();
}
e.printStackTrace(listener.error(msg));
} catch (AbortException e) {
listener.getLogger().println(e.getMessage());
} catch (IOException e) {
e.printStackTrace(listener.getLogger());
} finally {
return rval;
callables.add(() -> {
Boolean rval = Boolean.FALSE;
try {
String[] preferredKeyAlgorithms = getSshHostKeyVerificationStrategyDefaulted().getPreferredKeyAlgorithms(computer);
if (preferredKeyAlgorithms != null && preferredKeyAlgorithms.length > 0) { // JENKINS-44832
connection.setServerHostKeyAlgorithms(preferredKeyAlgorithms);
} else {
listener.getLogger().println("Warning: no key algorithms provided; JENKINS-42959 disabled");
}

listener.getLogger().println(logConfiguration());

openConnection(listener, computer);

verifyNoHeaderJunk(listener);
reportEnvironment(listener);

final String workingDirectory = getWorkingDirectory(computer);
if (workingDirectory == null) {
listener.error("Cannot get the working directory for " + computer);
return Boolean.FALSE;
}

String java = null;
if (StringUtils.isNotBlank(javaPath)) {
java = expandExpression(computer, javaPath);
} else {
checkJavaIsInPath(listener);
//FIXME deprecated on 2020-12-10, it will removed after 2021-09-01
JavaVersionChecker javaVersionChecker = new JavaVersionChecker(computer, listener, getJvmOptions(),
connection);
java = javaVersionChecker.resolveJava();
}

copyAgentJar(listener, workingDirectory);

startAgent(computer, listener, java, workingDirectory);

PluginImpl.register(connection);
rval = Boolean.TRUE;
} catch (RuntimeException|Error e) {
String msg = Messages.SSHLauncher_UnexpectedError();
if(StringUtils.isNotBlank(e.getMessage())){
msg = e.getMessage();
}
e.printStackTrace(listener.error(msg));
} catch (AbortException e) {
listener.getLogger().println(e.getMessage());
} catch (IOException e) {
e.printStackTrace(listener.getLogger());
} finally {
return rval;
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public String getDisplayName() {
}

public String getAgentNames() {
return agentNames != null ? agentNames.toString() : "";
return agentNames != null ? agentNames.toString() : "";
}

@Override
public boolean isSecurity() {
return true;
}
}
12 changes: 4 additions & 8 deletions src/test/java/hudson/plugins/sshslaves/SSHLauncherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -154,12 +155,7 @@ private static boolean checkSupported(final String testVersionOutput) throws IOE
}

private static void assertNotSupported(final String testVersionOutput) throws AssertionError {
try {
checkSupported(testVersionOutput);
fail("Expected version " + testVersionOutput + " to be not supported, but it is supported");
} catch (IOException e) {
// expected
}
assertThrows(IOException.class, () -> checkSupported(testVersionOutput));
}

private void checkRoundTrip(String host) throws Exception {
Expand Down Expand Up @@ -400,7 +396,7 @@ public void getMd5Hash() {
try {
byte[] bytes = "Leave me alone!".getBytes();
String result = SSHLauncher.getMd5Hash(bytes);
assertTrue("1EB226C8E950BAC1494BE197E84A264C".equals(result));
assertEquals("1EB226C8E950BAC1494BE197E84A264C", result);
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -420,7 +416,7 @@ public void readInputStreamIntoByteArrayAndClose() {
byte[] bytes = SSHLauncher.readInputStreamIntoByteArrayAndClose(inputStream);
assertNotNull(bytes);
assertTrue(bytes.length > 0);
assertTrue("Don't change me or add newlines!".equals(new String(bytes)));
assertEquals("Don't change me or add newlines!", new String(bytes));

} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import hudson.plugins.sshslaves.categories.AgentSSHTest;
import hudson.plugins.sshslaves.categories.SSHKeyAuthenticationTest;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;

/**
* Connect to a remote SSH Agent
*
* @author Kuisathaverat
*/
@Ignore("Only for manual test.")
@Category({ AgentSSHTest.class, SSHKeyAuthenticationTest.class})
public class AgentDSAConnectionTest extends AgentConnectionBase {
public static final String SSH_AGENT_NAME = "ssh-agent-dsa";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import hudson.plugins.sshslaves.categories.AgentSSHTest;
import hudson.plugins.sshslaves.categories.SSHKexTest;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;

/**
* Connect to a remote SSH Agent
*
* @author Kuisathaverat
*/
@Ignore("Only for manual test.")
@Category({ AgentSSHTest.class, SSHKexTest.class})
public class AgentECDHSha2Nistp256ConnectionTest extends AgentConnectionBase {
public static final String SSH_AGENT_NAME = "ssh-agent-ecdh-sha2-nistp256";
Expand Down
Loading