Skip to content

Commit cfc94cc

Browse files
committed
import prepared docker-inbound-agent files
2 parents 77850e6 + 9f8ab73 commit cfc94cc

8 files changed

Lines changed: 808 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Update Docker Hub Description
2+
on:
3+
release:
4+
types: [ published ]
5+
workflow_dispatch:
6+
7+
jobs:
8+
dockerHubDescription:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Update Docker Hub description
13+
uses: peter-evans/dockerhub-description@v3
14+
with:
15+
username: ${{ secrets.DOCKERHUB_USERNAME }}
16+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
17+
enable-url-completion: true
18+
short-description: ${{ github.event.repository.description }}
19+
repository: jenkins/inbound-agent

README_inbound-agent.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Docker image for inbound Jenkins agents
2+
3+
[![Join the chat at https://gitter.im/jenkinsci/docker](https://badges.gitter.im/jenkinsci/docker.svg)](https://gitter.im/jenkinsci/docker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4+
[![GitHub stars](https://img.shields.io/github/stars/jenkinsci/docker-inbound-agent?label=GitHub%20stars)](https://github.com/jenkinsci/docker-inbound-agent)
5+
[![Docker Pulls](https://img.shields.io/docker/pulls/jenkins/inbound-agent.svg)](https://hub.docker.com/r/jenkins/inbound-agent/)
6+
[![GitHub release](https://img.shields.io/github/release/jenkinsci/docker-inbound-agent.svg?label=changelog)](https://github.com/jenkinsci/docker-inbound-agent/releases/latest)
7+
8+
:exclamation: **Warning!** This image used to be published as [jenkinsci/jnlp-slave](https://hub.docker.com/r/jenkinsci/jnlp-slave/) and [jenkins/jnlp-slave](https://hub.docker.com/r/jenkins/jnlp-slave/).
9+
These images are deprecated, use [jenkins/inbound-agent](https://hub.docker.com/r/jenkins/inbound-agent/).
10+
11+
This is an image for [Jenkins](https://jenkins.io) agents using TCP or WebSockets to establish inbound connection to the Jenkins master.
12+
This agent is powered by the [Jenkins Remoting library](https://github.com/jenkinsci/remoting), which version is being taken from the base [Docker Agent](https://github.com/jenkinsci/docker-agent/) image.
13+
14+
See [Using Agents](https://www.jenkins.io/doc/book/using/using-agents/) for more info.
15+
16+
## Configuring agents with this container image
17+
18+
### Setup the agent on Jenkins
19+
20+
1. Go to your Jenkins dashboard
21+
2. Go to `Manage Jenkins` option in main menu
22+
3. Go to `Nodes` item in `System Configuration`
23+
![image](images/screen-4.png)
24+
4. Go to `New Node` option in side menu
25+
5. Fill the Node(agent) name and select the type; (e.g. Name: agent1, Type: Permanent Agent)
26+
6. Now fill the fields like remote root directory, labels, # of executors, etc.
27+
* **`Launch method` is `Launch agent by connecting it to the controller`**
28+
![image](images/screen-1.png)
29+
7. Press the `Save` button and the agent1 will be registered, but offline for the time being. Click on it.
30+
![image](images/screen-2.png)
31+
8. You should now see the secret. Use the secret value to pass it to the argument of container, or set to `JENKINS_SECRET` as environment variable.
32+
![image](images/screen-3.png)
33+
34+
### Running this container
35+
36+
To run a Docker container
37+
> **Note**
38+
> Remember to replace the `<secret>` and `<agent name>` for secret and agent name, which can be you can get(and set) from [above section](#Setup-the-agent-on-Jenkins).
39+
> Your agent node should be possible to connect to Jenkins controller with agent port (not Jenkins server's port like 80, 443, 8080), which can be set in `Manage Jenkins` > `Security` > `Agent`. Default port is 50000.
40+
41+
Linux agent:
42+
43+
docker run --init jenkins/inbound-agent -url http://jenkins-server:port <secret> <agent name>
44+
Note: `--init` is necessary for correct subprocesses handling (zombie reaping)
45+
46+
Windows agent:
47+
48+
docker run jenkins/inbound-agent:windowsservercore-ltsc2019 -Url http://jenkins-server:port -Secret <secret> -Name <agent name>
49+
50+
To run a Docker container with [Work Directory](https://github.com/jenkinsci/remoting/blob/master/docs/workDir.md)
51+
52+
Linux agent:
53+
54+
docker run --init jenkins/inbound-agent -url http://jenkins-server:port -workDir=/home/jenkins/agent <secret> <agent name>
55+
56+
Windows agent:
57+
58+
docker run jenkins/inbound-agent:windowsservercore-ltsc2019 -Url http://jenkins-server:port -WorkDir=C:/Jenkins/agent -Secret <secret> -Name <agent name>
59+
60+
Optional environment variables:
61+
62+
* `JENKINS_JAVA_BIN`: Path to Java executable to use instead of the default in PATH or obtained from JAVA_HOME
63+
* `JENKINS_JAVA_OPTS` : Java Options to use for the remoting process, otherwise obtained from JAVA_OPTS, **Warning** :exclamation: For more information on Windows usage, please see the **Windows Jenkins Java Opts** [section below](#windows-jenkins-java-opts).
64+
* `JENKINS_URL`: url for the Jenkins server, can be used as a replacement to `-url` option, or to set alternate jenkins URL
65+
* `JENKINS_TUNNEL`: (`HOST:PORT`) connect to this agent host and port instead of Jenkins server, assuming this one do route TCP traffic to Jenkins controller. Useful when when Jenkins runs behind a load balancer, reverse proxy, etc.
66+
* `JENKINS_SECRET`: (use only if not set as an argument) the secret as shown on the controller after creating the agent
67+
* `JENKINS_AGENT_NAME`: (use only if not set as an argument) the name of the agent, it should match the name you specified when creating the agent on the controller
68+
* `JENKINS_AGENT_WORKDIR`: agent work directory, if not set by optional parameter `-workDir`
69+
* `JENKINS_WEB_SOCKET`: `true` if the connection should be made via WebSocket rather than TCP
70+
* `JENKINS_DIRECT_CONNECTION`: (`HOST:PORT`) Connect directly to this TCP agent port, skipping the HTTP(S) connection parameter download.
71+
* `JENKINS_INSTANCE_IDENTITY`: The base64 encoded InstanceIdentity byte array of the Jenkins controller. When this is set, the agent skips connecting to an HTTP(S) port for connection info.
72+
* `JENKINS_PROTOCOLS`: Specify the remoting protocols to attempt when `JENKINS_INSTANCE_IDENTITY` is provided.
73+
74+
#### Example
75+
76+
1. Enter the command above.
77+
![image](images/screen-5.png)
78+
2. Check the Jenkins dashboard if the agent is connected well.
79+
![image](images/screen-6.png)
80+
81+
82+
## Windows Jenkins Java Opts
83+
84+
The processing of the JENKINS_JAVA_OPTS environment variable or -JenkinsJavaOpts command line parameter follow the [command parsing semantics of Powershell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parsing?view=powershell-7.3). This means that if a parameter contains any characters that are part of an expression in Powershell, it will need to be surrounded by quotes.
85+
For example:
86+
87+
-XX:+PrintCommandLineFlags --show-version
88+
89+
This would need to be escaped with quotes like this:
90+
91+
"-XX:+PrintCommandLineFlags" --show-version
92+
93+
Or another example:
94+
-Dsome.property=some value --show-version
95+
96+
This would need to be escaped like this:
97+
98+
"-Dsome.property='some value'" --show-version
99+
100+
101+
## Configuration specifics
102+
103+
### Enabled JNLP protocols
104+
105+
As of version 3.40-1 this image only supports the [JNLP4-connect](https://github.com/jenkinsci/remoting/blob/master/docs/protocols.md#jnlp4-connect) protocol.
106+
Earlier, long-unsupported protocols have been removed.
107+
As a result, Jenkins versions prior to 2.32 are no longer supported.
108+
109+
### Amazon ECS
110+
111+
Make sure your ECS container agent is [updated](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-update.html) before running. Older versions do not properly handle the entryPoint parameter. See the [entryPoint](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definitions) definition for more information.

jenkins-agent

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/usr/bin/env sh
2+
3+
# The MIT License
4+
#
5+
# Copyright (c) 2015-2020, CloudBees, Inc.
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in
15+
# all copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
# THE SOFTWARE.
24+
25+
# Usage jenkins-agent.sh [options] -url http://jenkins -secret [SECRET] -name [AGENT_NAME]
26+
# Optional environment variables :
27+
# * JENKINS_JAVA_BIN : Java executable to use instead of the default in PATH or obtained from JAVA_HOME
28+
# * JENKINS_JAVA_OPTS : Java Options to use for the remoting process, otherwise obtained from JAVA_OPTS
29+
# * JENKINS_TUNNEL : HOST:PORT for a tunnel to route TCP traffic to jenkins host, when jenkins can't be directly accessed over network
30+
# * JENKINS_URL : alternate jenkins URL
31+
# * JENKINS_SECRET : agent secret, if not set as an argument
32+
# * JENKINS_AGENT_NAME : agent name, if not set as an argument
33+
# * JENKINS_AGENT_WORKDIR : agent work directory, if not set by optional parameter -workDir
34+
# * JENKINS_WEB_SOCKET: true if the connection should be made via WebSocket rather than TCP
35+
# * JENKINS_DIRECT_CONNECTION: Connect directly to this TCP agent port, skipping the HTTP(S) connection parameter download.
36+
# Value: "<HOST>:<PORT>"
37+
# * JENKINS_INSTANCE_IDENTITY: The base64 encoded InstanceIdentity byte array of the Jenkins controller. When this is set,
38+
# the agent skips connecting to an HTTP(S) port for connection info.
39+
# * JENKINS_PROTOCOLS: Specify the remoting protocols to attempt when instanceIdentity is provided.
40+
41+
if [ $# -eq 1 ] && [ "${1#-}" = "$1" ] ; then
42+
43+
# if `docker run` only has one arguments and it is not an option as `-help`, we assume user is running alternate command like `bash` to inspect the image
44+
exec "$@"
45+
46+
else
47+
48+
# if -tunnel is not provided, try env vars
49+
case "$@" in
50+
*"-tunnel "*) ;;
51+
*)
52+
if [ ! -z "$JENKINS_TUNNEL" ]; then
53+
TUNNEL="-tunnel $JENKINS_TUNNEL"
54+
fi ;;
55+
esac
56+
57+
# if -workDir is not provided, try env vars
58+
if [ ! -z "$JENKINS_AGENT_WORKDIR" ]; then
59+
case "$@" in
60+
*"-workDir"*) echo "Warning: Work directory is defined twice in command-line arguments and the environment variable" ;;
61+
*)
62+
WORKDIR="-workDir $JENKINS_AGENT_WORKDIR" ;;
63+
esac
64+
fi
65+
66+
if [ -n "$JENKINS_URL" ]; then
67+
URL="-url $JENKINS_URL"
68+
fi
69+
70+
if [ -n "$JENKINS_NAME" ]; then
71+
JENKINS_AGENT_NAME="$JENKINS_NAME"
72+
fi
73+
74+
if [ "$JENKINS_WEB_SOCKET" = true ]; then
75+
WEB_SOCKET=-webSocket
76+
fi
77+
78+
if [ -n "$JENKINS_PROTOCOLS" ]; then
79+
PROTOCOLS="-protocols $JENKINS_PROTOCOLS"
80+
fi
81+
82+
if [ -n "$JENKINS_DIRECT_CONNECTION" ]; then
83+
DIRECT="-direct $JENKINS_DIRECT_CONNECTION"
84+
fi
85+
86+
if [ -n "$JENKINS_INSTANCE_IDENTITY" ]; then
87+
INSTANCE_IDENTITY="-instanceIdentity $JENKINS_INSTANCE_IDENTITY"
88+
fi
89+
90+
if [ "$JENKINS_JAVA_BIN" ]; then
91+
JAVA_BIN="$JENKINS_JAVA_BIN"
92+
else
93+
# if java home is defined, use it
94+
JAVA_BIN="java"
95+
if [ "$JAVA_HOME" ]; then
96+
JAVA_BIN="$JAVA_HOME/bin/java"
97+
fi
98+
fi
99+
100+
if [ "$JENKINS_JAVA_OPTS" ]; then
101+
JAVA_OPTIONS="$JENKINS_JAVA_OPTS"
102+
else
103+
# if JAVA_OPTS is defined, use it
104+
if [ "$JAVA_OPTS" ]; then
105+
JAVA_OPTIONS="$JAVA_OPTS"
106+
fi
107+
fi
108+
109+
# if both required options are defined, do not pass the parameters
110+
if [ -n "$JENKINS_SECRET" ]; then
111+
case "$@" in
112+
*"${JENKINS_SECRET}"*) echo "Warning: SECRET is defined twice in command-line arguments and the environment variable" ;;
113+
*)
114+
SECRET="-secret ${JENKINS_SECRET}" ;;
115+
esac
116+
fi
117+
118+
if [ -n "$JENKINS_AGENT_NAME" ]; then
119+
case "$@" in
120+
*"${JENKINS_AGENT_NAME}"*) echo "Warning: AGENT_NAME is defined twice in command-line arguments and the environment variable" ;;
121+
*)
122+
AGENT_NAME="-name ${JENKINS_AGENT_NAME}" ;;
123+
esac
124+
fi
125+
126+
#TODO: Handle the case when the command-line and Environment variable contain different values.
127+
#It is fine it blows up for now since it should lead to an error anyway.
128+
129+
exec $JAVA_BIN $JAVA_OPTIONS -jar /usr/share/jenkins/agent.jar $SECRET $AGENT_NAME $TUNNEL $URL $WORKDIR $WEB_SOCKET $DIRECT $PROTOCOLS $INSTANCE_IDENTITY "$@"
130+
131+
fi

0 commit comments

Comments
 (0)