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
Changes from 2 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
15 changes: 12 additions & 3 deletions jenkins-agent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Param(
$InstanceIdentity = '',
$Protocols = '',
$JenkinsJavaBin = '',
$JavaHome = $env:JAVA_HOME
$JavaHome = $env:JAVA_HOME,
$JavaOpts = ''
)

# Usage jenkins-agent.ps1 [options] -Url http://jenkins -Secret [SECRET] -Name [AGENT_NAME]
Expand All @@ -55,7 +56,6 @@ if(![System.String]::IsNullOrWhiteSpace($Cmd)) {
# if `docker run` only has one argument, we assume user is running alternate command like `powershell` or `pwsh` to inspect the image
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 = @{
Expand All @@ -69,6 +69,7 @@ if(![System.String]::IsNullOrWhiteSpace($Cmd)) {
'DirectConnection' = 'JENKINS_DIRECT_CONNECTION';
'InstanceIdentity' = 'JENKINS_INSTANCE_IDENTITY';
'Protocols' = 'JENKINS_PROTOCOLS';
'JavaOpts' = 'JAVA_OPTS';
slide marked this conversation as resolved.
Show resolved Hide resolved
}

# this does some trickery to update the variable from the CmdletBinding
Expand All @@ -92,6 +93,14 @@ if(![System.String]::IsNullOrWhiteSpace($Cmd)) {
}
}

$AgentArguments = @()

if(![System.String]::IsNullOrWhiteSpace($JavaOpts)) {
$AgentArguments += @($JavaOpts.split(" "))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the JavaOpts contains a quoted string with spaces?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it doesn't work. I found some scripts like https://github.com/beatcracker/Powershell-Misc/blob/master/Split-CommandLine.ps1 that would be able to do the splitting correctly but I don't have the correct environment to test it atm.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can test out when I am back from my vacation.

Copy link
Contributor

@Dohbedoh Dohbedoh Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually necessary to split it ? maybe it can just be added as is..

Per https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-7.2#parameters:

Arguments can be accepted as a single string with the arguments separated by spaces, or as an array of strings separated by commas. The cmdlet joins the array into a single string with each element of the array separated by a single space.

The outer quotes of the PowerShell strings are not included when the ArgumentList values are passed to the new process. If parameters or parameter values contain a space or quotes, they need to be surrounded with escaped double quotes. For more information, see [about_Quoting_Rules](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7.2).

So we should be able to do something like this no ?

        if (![System.String]::IsNullOrWhiteSpace($javaOpts)) {
            $AgentArguments += @(`"$javaOpts`")
        }

I haven't tested that but noticed this as part of #261

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the whole $AgentArguments should be a string in that case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice, this wasn't there when I initially wrote this PR. Will have a look.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

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

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

if(![System.String]::IsNullOrWhiteSpace($Protocols)) {
$AgentArguments += @('-protocols', $Protocols)
}
Expand Down