Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Allows to pass JAVA_OPTS to the JVM on windows #227

Merged
merged 74 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
bbefe48
Allows to pass JAVA_OPTS to the JVM
Vlatombe May 24, 2021
c2a2a0f
Merge branch 'master' into windows_javaopts
MarkEWaite Nov 20, 2021
fbc67e1
Remoting 4.11.2
MarkEWaite Dec 6, 2021
b50c46d
Build agent newer agent image (#253)
timja Jan 3, 2022
93e8f99
Add Java 17 alpine (#252)
Jan 3, 2022
e6fa6a2
Allow the use of multiple arguments (#254)
basil Jan 15, 2022
b473762
Revert "Allow the use of multiple arguments" (#257)
timja Jan 17, 2022
ec42eb0
Specify JENKINS_JAVA_OPTS to pass JVM options that apply to the agent…
Dohbedoh Mar 9, 2022
123d54d
Move away from deprecated Release Drafter App (#262)
NotMyFault Mar 9, 2022
5c27e04
Remove `--add-opens` directives on Java 17 (#263)
basil Mar 11, 2022
0737c8b
Bump remoting version (#264)
timja Mar 12, 2022
e6718ae
Use jenkins/agent:4.13-2
MarkEWaite Apr 20, 2022
fde53e5
Clarify build number comment
MarkEWaite Apr 20, 2022
11f80cd
Don't need to change BUILD_NUMBER
MarkEWaite Apr 20, 2022
eca3988
Now builds also for `linux/arm/v7`. (#269)
gounthar Jul 14, 2022
ff9a12e
Use build number 2 of agent image
timja Sep 3, 2022
39b51ef
Remove "-preview" from Java 17 images
jbarlin Aug 25, 2022
08e2b9d
Remove preview from build-arg
timja Sep 3, 2022
0aeed4c
Stop publishing jdk 8 remoting on master branch
timja Sep 6, 2022
9b4d12a
Remove Java 8 (#278)
slide Sep 25, 2022
11b10b5
Update base image to latest remoting (#281)
timja Sep 25, 2022
c47c410
fix: only deploy to DockerHub on tag-triggered builds
dduportal Sep 23, 2022
e00c935
code review + cleanup
dduportal Sep 29, 2022
7ff4429
code review
dduportal Sep 29, 2022
cd4ff6f
chore(Release Drafter) switch to reusable action, use static draft na…
dduportal Sep 29, 2022
f013c45
feat: bump remoting to 3063.v26e24490f041 (jenkins/agent with '-1') a…
dduportal Sep 29, 2022
5f6e523
fixup
dduportal Sep 29, 2022
e4f2439
fixup
dduportal Sep 29, 2022
956c415
hotfix(windows) fix deploy error on the pipeline
dduportal Sep 29, 2022
bbac764
hotfix(windows) correct pipeline error when deploying
dduportal Sep 29, 2022
c7da3c7
chore(test) fix build argument tests by using an old version
dduportal Sep 29, 2022
d1fbedc
Drop ppc64le support
MarkEWaite Oct 7, 2022
d53f770
Do not check Java 8 dependencies
MarkEWaite Oct 7, 2022
294df00
Bump remoting to `3071.v7e9b 0dc08466` (both parent image tag and inc…
dduportal Oct 31, 2022
8a1a06b
chore(updatecli) add a manifest to track the parent image version
dduportal Nov 11, 2022
e5bdca0
fixup
dduportal Nov 11, 2022
f318f70
Bump updatecli/updatecli-action from 2.13.0 to 2.14.0
dependabot[bot] Nov 11, 2022
8e3b7f6
Bump actions/checkout from 2 to 3
dependabot[bot] Nov 11, 2022
8c7c6c1
chore(linux tests) apply shellcheck and fix concurency issues
dduportal Nov 12, 2022
0d2e477
fixup
dduportal Nov 12, 2022
ed10d1f
chore(updateci) hotfix on the parent-image manifest
dduportal Nov 17, 2022
762d1c5
chore: changed lines [24] of file "/tmp/updatecli/github/jenkinsci/do…
github-actions[bot] Nov 18, 2022
1e8af14
chore: changed lines [24] of file "/tmp/updatecli/github/jenkinsci/do…
github-actions[bot] Nov 18, 2022
129ebc6
chore: changed lines [24] of file "/tmp/updatecli/github/jenkinsci/do…
github-actions[bot] Nov 18, 2022
f910d82
chore: changed lines [24] of file "/tmp/updatecli/github/jenkinsci/do…
github-actions[bot] Nov 18, 2022
94b9aeb
chore: changed lines [24] of file "/tmp/updatecli/github/jenkinsci/do…
github-actions[bot] Nov 18, 2022
359bde0
chore: changed lines [24] of file "/tmp/updatecli/github/jenkinsci/do…
github-actions[bot] Nov 18, 2022
888f4da
chore: changed lines [24] of file "/tmp/updatecli/github/jenkinsci/do…
github-actions[bot] Nov 18, 2022
1595958
chore: changed lines [24] of file "/tmp/updatecli/github/jenkinsci/do…
github-actions[bot] Nov 18, 2022
e59a1ef
chore: changed lines [24] of file "/tmp/updatecli/github/jenkinsci/do…
github-actions[bot] Nov 18, 2022
5bb3d40
chore: changed lines [24] of file "/tmp/updatecli/github/jenkinsci/do…
github-actions[bot] Nov 18, 2022
248f56c
chore(updatecli) adapt manifest for v0.38.0
dduportal Nov 20, 2022
00b0112
chore: changed lines [1 4] of file "/tmp/updatecli/github/jenkinsci/d…
github-actions[bot] Nov 20, 2022
48cd7c5
chore: changed lines [1 4] of file "/tmp/updatecli/github/jenkinsci/d…
github-actions[bot] Nov 20, 2022
8977752
chore: changed lines [1 4] of file "/tmp/updatecli/github/jenkinsci/d…
github-actions[bot] Nov 20, 2022
ee0dc06
chore: changed lines [1 4] of file "/tmp/updatecli/github/jenkinsci/d…
github-actions[bot] Nov 20, 2022
6062647
chore: changed lines [1 4] of file "/tmp/updatecli/github/jenkinsci/d…
github-actions[bot] Nov 20, 2022
5597314
chore: changed lines [1 4] of file "/tmp/updatecli/github/jenkinsci/d…
github-actions[bot] Nov 20, 2022
c3bb432
chore: changed lines [1 4] of file "/tmp/updatecli/github/jenkinsci/d…
github-actions[bot] Nov 20, 2022
080153c
chore: changed lines [1 4] of file "/tmp/updatecli/github/jenkinsci/d…
github-actions[bot] Nov 20, 2022
d04e5f4
chore: changed lines [1 4] of file "/tmp/updatecli/github/jenkinsci/d…
github-actions[bot] Nov 20, 2022
2ef5516
chore: changed lines [1 4] of file "/tmp/updatecli/github/jenkinsci/d…
github-actions[bot] Nov 20, 2022
d0d4aaa
chore: changed lines [23 26] of file "/tmp/updatecli/github/jenkinsci…
github-actions[bot] Nov 23, 2022
041099e
chore: changed lines [23 26] of file "/tmp/updatecli/github/jenkinsci…
github-actions[bot] Nov 23, 2022
579ba2c
chore: changed lines [23 26] of file "/tmp/updatecli/github/jenkinsci…
github-actions[bot] Nov 23, 2022
4faaaa2
chore: changed lines [23 26] of file "/tmp/updatecli/github/jenkinsci…
github-actions[bot] Nov 23, 2022
d817009
chore: changed lines [23 26] of file "/tmp/updatecli/github/jenkinsci…
github-actions[bot] Nov 23, 2022
bbb0c02
chore: changed lines [23 26] of file "/tmp/updatecli/github/jenkinsci…
github-actions[bot] Nov 23, 2022
b29e9d0
chore: changed lines [23 26] of file "/tmp/updatecli/github/jenkinsci…
github-actions[bot] Nov 23, 2022
005a073
chore: changed lines [23 26] of file "/tmp/updatecli/github/jenkinsci…
github-actions[bot] Nov 23, 2022
2ff5bc4
chore: changed lines [23 26] of file "/tmp/updatecli/github/jenkinsci…
github-actions[bot] Nov 23, 2022
49cc081
chore: changed lines [23 26] of file "/tmp/updatecli/github/jenkinsci…
github-actions[bot] Nov 23, 2022
dd9d59d
Fixup command line processing and add test
slide Nov 24, 2022
2c26e1e
Merge branch 'master' into windows_javaopts
slide Nov 24, 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
23 changes: 19 additions & 4 deletions jenkins-agent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

[CmdletBinding()]
Param(
$Cmd = '', # this is only used when docker run has one arg positional arg
$Cmd = '', # this must be specified explicitly
$Url = $( if([System.String]::IsNullOrWhiteSpace($Cmd) -and [System.String]::IsNullOrWhiteSpace($env:JENKINS_URL)) { throw ("Url is required") } else { '' } ),
[Parameter(Position=0)]$Secret = $( if([System.String]::IsNullOrWhiteSpace($Cmd) -and [System.String]::IsNullOrWhiteSpace($env:JENKINS_SECRET)) { throw ("Secret is required") } else { '' } ),
[Parameter(Position=1)]$Name = $( if([System.String]::IsNullOrWhiteSpace($Cmd) -and [System.String]::IsNullOrWhiteSpace($env:JENKINS_AGENT_NAME)) { throw ("Name is required") } else { '' } ),
Expand All @@ -33,12 +33,14 @@ Param(
$InstanceIdentity = '',
$Protocols = '',
$JenkinsJavaBin = '',
$JavaHome = $env:JAVA_HOME
$JavaHome = $env:JAVA_HOME,
$JenkinsJavaOpts = ''
)

# Usage jenkins-agent.ps1 [options] -Url http://jenkins -Secret [SECRET] -Name [AGENT_NAME]
# Optional environment variables :
# * JENKINS_JAVA_BIN : Java executable to use instead of the default in PATH or obtained from JAVA_HOME
# * JENKINS_JAVA_OPTS : Java Options to use for the remoting process, otherwise obtained from JAVA_OPTS
# * JENKINS_TUNNEL : HOST:PORT for a tunnel to route TCP traffic to jenkins host, when jenkins can't be directly accessed over network
# * JENKINS_URL : alternate jenkins URL
# * JENKINS_SECRET : agent secret, if not set as an argument
Expand All @@ -54,11 +56,11 @@ Param(
if(![System.String]::IsNullOrWhiteSpace($Cmd)) {
Invoke-Expression "$Cmd"
} else {
$AgentArguments = @("-cp", "C:/ProgramData/Jenkins/agent.jar", "hudson.remoting.jnlp.Main", "-headless")

# this maps the variable name from the CmdletBinding to environment variables
$ParamMap = @{
'JenkinsJavaBin' = 'JENKINS_JAVA_BIN';
'JenkinsJavaOpts' = 'JENKINS_JAVA_OPTS';
'Tunnel' = 'JENKINS_TUNNEL';
'Url' = 'JENKINS_URL';
'Secret' = 'JENKINS_SECRET';
Expand Down Expand Up @@ -91,6 +93,19 @@ if(![System.String]::IsNullOrWhiteSpace($Cmd)) {
}
}

$AgentArguments = @()

if(![System.String]::IsNullOrWhiteSpace($JenkinsJavaOpts)) {
# this magic will basically process the $JenkinsJavaOpts like a command line
# and split into an array, the command line processing follows the PowerShell
# commnd line processing, which means for things like -Dsomething.something=something,
# you need to quote the string like this: "-Dsomething.something=something" or else it
# will get parsed incorrectly.
$AgentArguments += Invoke-Expression "echo $JenkinsJavaOpts"
}

$AgentArguments += @("-cp", "C:/ProgramData/Jenkins/agent.jar", "hudson.remoting.jnlp.Main", "-headless")

if(![System.String]::IsNullOrWhiteSpace($Tunnel)) {
$AgentArguments += @("-tunnel", "`"$Tunnel`"")
}
Expand All @@ -116,7 +131,7 @@ if(![System.String]::IsNullOrWhiteSpace($Cmd)) {
if(![System.String]::IsNullOrWhiteSpace($InstanceIdentity)) {
$AgentArguments += @('-instanceIdentity', $InstanceIdentity)
}

if(![System.String]::IsNullOrWhiteSpace($Protocols)) {
$AgentArguments += @('-protocols', $Protocols)
}
Expand Down
35 changes: 34 additions & 1 deletion tests/inboundAgent.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ Describe "[$global:JDK $global:FLAVOR] build image" {

It 'builds image' {
$exitCode, $stdout, $stderr = Run-Program 'docker.exe' "build --build-arg VERSION=$global:VERSION -t $global:AGENT_IMAGE $global:FOLDER"
# This failure was added on purpose to verify that the build will fail if a test fails
$exitCode | Should -Be 0
}

Expand Down Expand Up @@ -172,3 +171,37 @@ Describe "[$global:JDK $global:FLAVOR] build args" {
Pop-Location -StackName 'agent'
}
}


Describe "[$global:JDK $global:FLAVOR] passing JVM options (slow test)" {
It "shows the java version with --show-version" {
$exitCode, $stdout, $stderr = Run-Program 'docker.exe' "network create --driver nat jnlp-network"
# Launch the netcat utility, listening at port 5000 for 30 sec
# bats will capture the output from netcat and compare the first line
# of the header of the first HTTP request with the expected one
$exitCode, $stdout, $stderr = Run-Program 'docker.exe' "run -dit --name nmap --network=jnlp-network nmap:latest ncat.exe -w 30 -l 5000"
$exitCode | Should -Be 0
Is-ContainerRunning "nmap" | Should -BeTrue

# get the ip address of the nmap container
$exitCode, $stdout, $stderr = Run-Program 'docker.exe' "inspect -f `"{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}`" nmap"
$exitCode | Should -Be 0
$nmap_ip = $stdout.Trim()

# run Jenkins agent which tries to connect to the nmap container at port 5000
$secret = "aaa"
$name = "bbb"
$exitCode, $stdout, $stderr = Run-Program 'docker.exe' "run -dit --network=jnlp-network --name $global:AGENT_CONTAINER $global:AGENT_IMAGE -Url http://${nmap_ip}:5000 -JenkinsJavaOpts `"--show-version`" $secret $name"
$exitCode | Should -Be 0
Is-ContainerRunning $global:AGENT_CONTAINER | Should -BeTrue
$exitCode, $stdout, $stderr = Run-Program 'docker.exe' "logs $global:AGENT_CONTAINER"
$exitCode | Should -Be 0
$stdout | Should -Match "OpenJDK Runtime Environment Temurin-${global:JDK}"
}

AfterAll {
Cleanup($global:AGENT_CONTAINER)
Cleanup("nmap")
CleanupNetwork("jnlp-network")
}
}