Skip to content

Port Bindings Failing #1156

@noah-wolton

Description

@noah-wolton

Jenkins and plugins versions report

Environment
Jenkins: 2.492.2
OS: Linux - 5.15.167.4-microsoft-standard-WSL2
Java: 17.0.14 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
PrioritySorter:863.v4a_b_974a_5d042
analysis-model-api:13.2.0
ant:513.vde9e7b_a_0da_0f
antisamy-markup-formatter:173.v680e3a_b_69ff3
apache-httpcomponents-client-4-api:4.5.14-269.vfa_2321039a_83
apache-httpcomponents-client-5-api:5.5-150.veb_76e719855b_
asm-api:9.8-135.vb_2239d08ee90
authentication-tokens:1.131.v7199556c3004
bootstrap5-api:5.3.3-2
bouncycastle-api:2.30.1.80-261.v00c0e2618ec3
branch-api:2.1217.v43d8b_b_d8b_2c7
build-name-setter:2.5.0
build-timeout:1.38
caffeine-api:3.2.0-166.v72a_6d74b_870f
checks-api:370.vb_61a_c57328f3
cloud-stats:377.vd8a_6c953e98e
cloudbees-folder:6.1023.v4fcb_72152519
command-launcher:123.v37cfdc92ef67
commons-compress-api:1.27.1-3
commons-lang3-api:3.17.0-87.v5cf526e63b_8b_
commons-text-api:1.13.1-176.v74d88f22034b_
configuration-as-code:1963.v24e046127a_3f
copy-data-to-workspace-plugin:63.ve6c51d760236
copyartifact:770.va_6c69e063442
credentials:1415.v831096eb_5534
credentials-binding:687.v619cb_15e923f
dark-theme:524.vd675b_22b_30cb_
data-tables-api:2.2.2-1
display-url-api:2.209.v582ed814ff2f
docker-commons:457.v0f62a_94f11a_3
docker-java-api:3.5.1-116.v2798d5ed4ce7
docker-plugin:1274.vc0203fdf2e74
docker-workflow:621.va_73f881d9232
durable-task:587.v84b_877235b_45
echarts-api:5.6.0-4
eddsa-api:0.3.0.1-19.vc432d923e5ee
email-ext:1876.v28d8d38315b_d
envinject:2.926.v69c9b_3896a_96
envinject-api:1.235.va_14c74f8f487
external-monitor-job:223.vb_fddcf42c9b_3
external-workspace-manager:1.3.1
file-operations:353.vf3b_9b_a_f1f7f7
font-awesome-api:6.7.2-1
forensics-api:3.1.0
git:5.7.0
git-client:6.1.3
git-parameter:439.vb_0e46ca_14534
git-server:137.ve0060b_432302
github:1.43.0
github-api:1.321-488.v9b_c0da_9533f8
github-branch-source:1822.v9eec8e5e69e3
gradle:2.15
gson-api:2.13.1-139.v4569c2ef303f
instance-identity:203.v15e81a_1b_7a_38
ionicons-api:88.va_4187cb_eddf1
jackson2-api:2.18.3-402.v74c4eb_f122b_2
jakarta-activation-api:2.1.3-2
jakarta-mail-api:2.1.3-2
javax-activation-api:1.2.0-8
javax-mail-api:1.6.2-11
jaxb:2.3.9-133.vb_ec76a_73f706
jdk-tool:83.v417146707a_3d
jersey2-api:2.45-154.v4ded3dc34f81
jira:3.16
jjwt-api:0.11.5-120.v0268cf544b_89
job-restrictions:216.v0732cc7fb_076
joda-time-api:2.14.0-127.v7d9da_295a_d51
jquery3-api:3.7.1-3
json-api:20250517-153.vc8a_a_d87c0ce3
json-path-api:2.9.0-148.v22a_7ffe323ce
jsoup:1.20.1-46.ve5f1416988c2
junit:1335.v6b_a_a_e18534e1
ldap:780.vcb_33c9a_e4332
lockable-resources:1349.v8b_ccb_c5487f7
mailer:489.vd4b_25144138f
mapdb-api:1.0.9-44.va_1e1310c9118
matrix-auth:3.2.6
matrix-project:849.v0cd64ed7e531
metrics:4.2.32-476.v5042e1c1edd7
mina-sshd-api-common:2.15.0-161.vb_200831a_c15b_
mina-sshd-api-core:2.15.0-161.vb_200831a_c15b_
monitoring:2.5.0
msbuild:1.36
naginator:1.504.vfc3736332f16
nested-view:239.vb_8c100b_46b_a_8
okhttp-api:4.11.0-189.v976fa_d3379d6
pam-auth:1.12
pipeline-build-step:567.vea_ce550ece97
pipeline-github:2.8-162.382498405fdc
pipeline-github-lib:65.v203688e7727e
pipeline-graph-analysis:241.vc3d48fb_b_2582
pipeline-graph-view:551.vde72dc246b_c4
pipeline-groovy-lib:752.vdddedf804e72
pipeline-input-step:527.vd61b_1d3c5078
pipeline-milestone-step:138.v78ca_76831a_43
pipeline-model-api:2.2255.v56a_15e805f12
pipeline-model-definition:2.2255.v56a_15e805f12
pipeline-model-extensions:2.2255.v56a_15e805f12
pipeline-rest-api:2.38
pipeline-stage-step:322.vecffa_99f371c
pipeline-stage-tags-metadata:2.2255.v56a_15e805f12
pipeline-stage-view:2.38
pipeline-utility-steps:2.19.0
plain-credentials:195.vb_906e9073dee
plugin-util-api:6.1.0
prism-api:1.30.0-1
resource-disposer:0.25
role-strategy:775.vf7c4a_97194dd
scm-api:704.v3ce5c542825a_
script-security:1373.vb_b_4a_a_c26fa_00
short-workspace-path:0.3
simpletfsscm:1.0-SNAPSHOT (private-eff81b52-noahw)
slave-prerequisites:1.0
snakeyaml-api:2.3-125.v4d77857a_b_402
ssh-credentials:355.v9b_e5b_cde5003
ssh-slaves:3.1031.v72c6b_883b_869
sshd:3.353.v2b_d33c46e970
startup-trigger-plugin:2.9.4
structs:350.v3b_30f09f2363
subversion:1287.vd2d507146906
tfs:5.157.1
theme-manager:294.vf2c2fd783821
timestamper:1.29
token-macro:444.v52de7e9c573d
trilead-api:2.209.v0e69b_c43c245
variant:70.va_d9f17f859e0
warnings-ng:12.6.0
workflow-aggregator:608.v67378e9d3db_1
workflow-api:1373.v7b_813f10efa_b_
workflow-basic-steps:1079.vce64b_a_929c5a_
workflow-cps:4106.v7a_8a_8176d450
workflow-cps-global-lib:615.vb_b_0664a_b_19f3
workflow-durable-task-step:1405.v1fcd4a_d00096
workflow-job:1532.va_9a_d244074a_3
workflow-multibranch:806.vb_b_688f609ee9
workflow-scm-step:437.v05a_f66b_e5ef8
workflow-step-api:700.v6e45cb_a_5a_a_21
workflow-support:968.v8f17397e87b_8
ws-cleanup:0.48

What Operating System are you using (both controller, and any agents involved in the problem)?

Windows OS Docker through WSL 2 running Jenkins
Windows OS Docker through WSL 2 running Nodes which are dockurr/windows containers

Reproduction steps

  1. Create a Cloud
  2. Create an Agent Template
  3. Change the SSH Settings to connect with Configured Credentials
  4. Try every combination of port bindings and find out they a lot of the time they all fail.

Expected Results

Port bindings work correctly.

Actual Results

Either NullPointerException, or this error:
java.lang.NullPointerException: Cannot read the array length because "<parameter1>" is null at java.base/java.util.Arrays.stream(Unknown Source) at java.base/java.util.stream.Stream.of(Unknown Source) at PluginClassLoader for docker-plugin//io.jenkins.docker.connector.DockerComputerSSHConnector.getBindingForPort(DockerComputerSSHConnector.java:391)

Anything else?

Very very inconsistent, I had it working for a while with bind all ports ticked and "0:22" in the port binding box but then it broke for me again today and nothing I've tried has worked. It also for some ungodly reason decides to work the first time it runs after I restart my Jenkins container, then immediately break again.

Are you interested in contributing a fix?

So this might be just a problem specific to my setup and thankfully I am moving my docker setup to a linux machine soon (and I'm praying this will go away at that point), but in the mean time the problem seems to be related to these two lines (in DockerComputerSSHConnector.java in getBindingForPort):
378: final Ports.Binding[] sshBindings = bindings.get(sshPort);
391: final Ports.Binding b = Stream.of(sshBindings) .sorted(new HostPortComparator()) .findFirst() .orElse(null);
As 378 is returning null and 391 is then failing. Now by all rights line 378 should not be returning null in my situation as I've tried both exposing the port through the Dockerfile and every different binding option, but I think we should at least have some sort of check and at least an informative error message should sshBindings be null.

We could also try some sort of more extensive check if sshBindings is null or maybe a wait and then check to make sure that Docker isn't still processing something in the background? I'm a bit out of my depth so someone with better expertise would be massively appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions