This repository has been archived by the owner on Jan 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will require the PR for https://github.com/jenkinsci/docker-slave to be merged and pushed to docker hub.
- Loading branch information
Showing
4 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# The MIT License | ||
# | ||
# Copyright (c) 2019, Alex Earl | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
FROM jenkins/agent:latest-windows | ||
MAINTAINER Alex Earl <slide.o.mix@gmail.com> | ||
LABEL Description="This is a base image, which allows connecting Jenkins agents via JNLP protocols on Windows" Vendor="Jenkins Project" Version="3.29" | ||
|
||
COPY jenkins-agent.ps1 C:/ProgramData/Jenkins | ||
ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Jenkins/jenkins-agent.ps1"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,11 +16,23 @@ See [Jenkins Distributed builds](https://wiki.jenkins-ci.org/display/JENKINS/Dis | |
|
||
To run a Docker container | ||
|
||
Linux agent: | ||
|
||
docker run jenkins/jnlp-slave -url http://jenkins-server:port <secret> <agent name> | ||
|
||
To run a Docker container with [Work Directory](https://github.com/jenkinsci/remoting/blob/master/docs/workDir.md): | ||
Windows agent: | ||
|
||
docker run jenkins/jnlp-agent:latest-windows -Url http://jenkins-server:port -Secret <secret> -Name <agent name> | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
oleg-nenashev
Member
|
||
|
||
To run a Docker container with [Work Directory](https://github.com/jenkinsci/remoting/blob/master/docs/workDir.md) | ||
|
||
Linux agent: | ||
|
||
docker run jenkins/jnlp-slave -url http://jenkins-server:port -workDir=/home/jenkins/agent <secret> <agent name> | ||
|
||
Windows agent: | ||
|
||
docker run jenkins/jnlp-agent-windows -Url http://jenkins-server:port -WorkDir=C:/Jenkins/agent -Secret <secret> -Name <agent name> | ||
This comment has been minimized.
Sorry, something went wrong.
darxriggs
|
||
|
||
Optional environment variables: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# The MIT License | ||
# | ||
# Copyright (c) 2019, Alex Earl | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
[CmdletBinding()] | ||
Param( | ||
$Cmd = '', # this is only used when docker run has one arg positional arg | ||
$Url = '', | ||
$Secret = '', | ||
$Name = '', | ||
$Tunnel = '', | ||
$WorkDir = 'C:/Users/jenkins/Agent', | ||
$JavaHome = $env:JAVA_HOME | ||
) | ||
|
||
# Usage jenkins-slave.ps1 [options] -Url http://jenkins -Secret [SECRET] -Name [AGENT_NAME] | ||
# Optional environment variables : | ||
# * 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 | ||
# * JENKINS_AGENT_NAME : agent name, if not set as an argument | ||
# * JENKINS_AGENT_WORKDIR : agent work directory, if not set by optional parameter -workDir | ||
|
||
if(![System.String]::IsNullOrWhiteSpace($Cmd)) { | ||
# if `docker run` only has one arguments, we assume user is running alternate command like `bash` to inspect the image | ||
Invoke-Expression "$Cmd" | ||
} else { | ||
# if -Tunnel is not provided, try env vars | ||
if(![System.String]::IsNullOrWhiteSpace($env:JENKINS_TUNNEL)) { | ||
if(![System.String]::IsNullOrWhiteSpace($Tunnel)) { | ||
Write-Warning "Tunnel is defined twice; in command-line arguments and the environment variable" | ||
} | ||
$Tunnel = $($env:JENKINS_TUNNEL).Trim() | ||
} | ||
$Tunnel = $Tunnel.Trim() | ||
if(![System.String]::IsNullOrWhiteSpace($Tunnel)) { | ||
$Tunnel = " -tunnel `"$Tunnel`"" | ||
} | ||
|
||
# if -WorkDir is not provided, try env vars | ||
if(![System.String]::IsNullOrWhiteSpace($env:JENKINS_AGENT_WORKDIR)) { | ||
if(![System.String]::IsNullOrWhiteSpace($WorkDir)) { | ||
Write-Warning "Work directory is defined twice; in command-line arguments and the environment variable" | ||
} | ||
$WorkDir = $env:JENKINS_AGENT_WORKDIR | ||
} | ||
$WorkDir = $WorkDir.Trim() | ||
if(![System.String]::IsNullOrWhiteSpace($WorkDir)) { | ||
$WorkDir = " -workDir `"$WorkDir`"" | ||
} | ||
|
||
# if -Url is not provided, try env vars | ||
if(![System.String]::IsNullOrWhiteSpace($env:JENKINS_URL)) { | ||
if(![System.String]::IsNullOrWhiteSpace($Url)) { | ||
Write-Warning "Url is defined twice; in command-line arguments and the environment variable" | ||
} | ||
$Url = $($env:JENKINS_URL).Trim() | ||
} | ||
$Url = $Url.Trim() | ||
if(![System.String]::IsNullOrWhiteSpace($Url)) { | ||
$Url = " -url `"$Url`"" | ||
} | ||
|
||
# if -Name is not provided, try env vars | ||
if(![System.String]::IsNullOrWhiteSpace($env:JENKINS_NAME)) { | ||
if(![System.String]::IsNullOrWhiteSpace($Name)) { | ||
Write-Warning "Name is defined twice; in command-line arguments and the environment variable" | ||
} | ||
$Name = $env:JENKINS_NAME | ||
} | ||
$Name = $Name.Trim() | ||
|
||
$jnlpProtocolOpts = '' | ||
if([System.String]::IsNullOrWhiteSpace($env:JNLP_PROTOCOL_OPTS)) { | ||
Write-Warning "JnlpProtocol3 is disabled by default, use JNLP_PROTOCOL_OPTS to alter the behavior" | ||
$jnlpProtocolOpts="-D`"org.jenkinsci.remoting.engine.JnlpProtocol3.disabled=true`"" | ||
} | ||
|
||
# if java home is defined, use it | ||
$JAVA_BIN="java.exe" | ||
if(![System.String]::IsNullOrWhiteSpace($JavaHome)) { | ||
$JAVA_BIN="$JavaHome/bin/java.exe" | ||
} | ||
|
||
# if -Url is not provided, try env vars | ||
if(![System.String]::IsNullOrWhiteSpace($env:JENKINS_SECRET)) { | ||
if(![System.String]::IsNullOrWhiteSpace($Secret)) { | ||
Write-Warning "Secret is defined twice; in command-line arguments and the environment variable" | ||
} | ||
$Secret = $env:JENKINS_SECRET | ||
} | ||
$Secret = $Secret.Trim() | ||
if(![System.String]::IsNullOrWhiteSpace($Secret)) { | ||
$Secret = " $Secret" | ||
} | ||
|
||
#TODO: Handle the case when the command-line and Environment variable contain different values. | ||
#It is fine it blows up for now since it should lead to an error anyway. | ||
Start-Process -FilePath $JAVA_BIN -Wait -NoNewWindow -ArgumentList $("$jnlpProtocolOpts -cp C:/ProgramData/Jenkins/agent.jar hudson.remoting.jnlp.Main -headless$Tunnel$Url$WorkDir$Secret $Name") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if([System.String]::IsNullOrWhiteSpace($env:IMAGE_NAME)) { | ||
$env:IMAGE_NAME='jenkins4eval/jnlp-agent:test-windows' | ||
} | ||
|
||
& docker build -f Dockerfile-windows -t $env:IMAGE_NAME . |
Is
jenkins/jnlp-agent:latest-windows
really correct? I cannot find such an image on Docker Hub.It this still waiting for jenkinsci/docker-agent#73?