|
| 1 | +# Docker image for inbound Jenkins agents |
| 2 | + |
| 3 | +[](https://gitter.im/jenkinsci/docker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
| 4 | +[](https://github.com/jenkinsci/docker-inbound-agent) |
| 5 | +[](https://hub.docker.com/r/jenkins/inbound-agent/) |
| 6 | +[](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 | +  |
| 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 | +  |
| 29 | +7. Press the `Save` button and the agent1 will be registered, but offline for the time being. Click on it. |
| 30 | +  |
| 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 | +  |
| 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 | +  |
| 78 | +2. Check the Jenkins dashboard if the agent is connected well. |
| 79 | +  |
| 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. |
0 commit comments