Skip to content

Commit a82d78a

Browse files
authored
Merge pull request #2815 from jglick/ktunnel
`-Pktunnel`
2 parents b59f230 + 26aad23 commit a82d78a

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ then
10151015
```bash
10161016
kubectl krew install tunnel # as needed; install Krew first
10171017
kubectl tunnel expose jenkins 8000:8000 8001:8001 &
1018-
mvn test -Djenkins.host.address=jenkins.default.svc.cluster.local -Dport=8000 -DslaveAgentPort=8001 -Dtest=KubernetesPipelineTest#runInPod
1018+
mvn test -Pktunnel -Dtest=KubernetesPipelineTest#runInPod
10191019
```
10201020

10211021
Alternately, you can run everything like in CI:
@@ -1028,7 +1028,7 @@ export KIND_PRELOAD=true # optionally
10281028
You can also run interactively after setting up the tunnel:
10291029

10301030
```bash
1031-
mvn hpi:run -Djenkins.host.address=jenkins.default -Dport=8000 -Djenkins.model.Jenkins.slaveAgentPort=8001
1031+
mvn hpi:run -Pktunnel
10321032
```
10331033

10341034
# Docker image

kind.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ ktunnel_pid=$!
5454
mvn \
5555
-B \
5656
-ntp \
57-
-Djenkins.host.address=jenkins.default \
58-
-Dport=8000 \
59-
-DslaveAgentPort=8001 \
57+
-Pktunnel \
6058
-Dmaven.test.failure.ignore \
6159
verify \
6260
"$@"

pom.xml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141

4242
<properties>
4343
<changelist>999999-SNAPSHOT</changelist>
44-
<jenkins.host.address />
45-
<slaveAgentPort />
4644
<jenkins.baseline>2.504</jenkins.baseline>
4745
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
4846
<no-test-jar>false</no-test-jar>
@@ -294,12 +292,7 @@
294292
<artifactId>maven-surefire-plugin</artifactId>
295293
<configuration>
296294
<systemPropertyVariables>
297-
<hudson.slaves.NodeProvisioner.initialDelay>0</hudson.slaves.NodeProvisioner.initialDelay>
298-
<hudson.slaves.NodeProvisioner.recurrencePeriod>3000</hudson.slaves.NodeProvisioner.recurrencePeriod>
299295
<org.jenkinsci.plugins.workflow.support.pickles.ExecutorPickle.timeoutForNodeMillis>60000</org.jenkinsci.plugins.workflow.support.pickles.ExecutorPickle.timeoutForNodeMillis>
300-
<!-- have pods connect to this address for Jenkins -->
301-
<jenkins.host.address>${jenkins.host.address}</jenkins.host.address>
302-
<slaveAgentPort>${slaveAgentPort}</slaveAgentPort>
303296
</systemPropertyVariables>
304297
</configuration>
305298
</plugin>
@@ -308,11 +301,6 @@
308301
<artifactId>maven-hpi-plugin</artifactId>
309302
<configuration>
310303
<systemProperties>
311-
<hudson.slaves.NodeProvisioner.initialDelay>0</hudson.slaves.NodeProvisioner.initialDelay>
312-
<hudson.slaves.NodeProvisioner.MARGIN>50</hudson.slaves.NodeProvisioner.MARGIN>
313-
<hudson.slaves.NodeProvisioner.MARGIN0>0.85</hudson.slaves.NodeProvisioner.MARGIN0>
314-
<jenkins.host.address>${jenkins.host.address}</jenkins.host.address>
315-
<port>${port}</port>
316304
<org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution.verbose>true</org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution.verbose>
317305
</systemProperties>
318306
</configuration>
@@ -388,6 +376,38 @@
388376
</plugins>
389377
</build>
390378
</profile>
379+
<profile>
380+
<!-- kubectl tunnel expose jenkins 8000:8000 8001:8001 -->
381+
<id>ktunnel</id>
382+
<build>
383+
<pluginManagement>
384+
<plugins>
385+
<plugin>
386+
<groupId>org.apache.maven.plugins</groupId>
387+
<artifactId>maven-surefire-plugin</artifactId>
388+
<configuration>
389+
<systemPropertyVariables>
390+
<jenkins.host.address>jenkins.default.svc.cluster.local</jenkins.host.address>
391+
<port>8000</port>
392+
<slaveAgentPort>8001</slaveAgentPort>
393+
</systemPropertyVariables>
394+
</configuration>
395+
</plugin>
396+
<plugin>
397+
<groupId>org.jenkins-ci.tools</groupId>
398+
<artifactId>maven-hpi-plugin</artifactId>
399+
<configuration>
400+
<defaultPort>8000</defaultPort>
401+
<systemProperties>
402+
<jenkins.host.address>jenkins.default.svc.cluster.local</jenkins.host.address>
403+
<jenkins.model.Jenkins.slaveAgentPort>8001</jenkins.model.Jenkins.slaveAgentPort>
404+
</systemProperties>
405+
</configuration>
406+
</plugin>
407+
</plugins>
408+
</pluginManagement>
409+
</build>
410+
</profile>
391411
</profiles>
392412

393413
</project>

src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ public static void hpiRunInit() {
14661466
&& jenkins.clouds.getAll(KubernetesCloud.class).isEmpty()) {
14671467
KubernetesCloud cloud = new KubernetesCloud("kubernetes");
14681468
cloud.setJenkinsUrl(
1469-
"http://" + hostAddress + ":" + SystemProperties.getInteger("port", 8080) + "/jenkins/");
1469+
"http://" + hostAddress + ":" + SystemProperties.getInteger("port", 8000) + "/jenkins/");
14701470
jenkins.clouds.add(cloud);
14711471
}
14721472
}

0 commit comments

Comments
 (0)