docker-ssh-agent

docker-ssh-agent

基于SSH的Jenkins代理Docker镜像 支持分布式构建

docker-ssh-agent项目提供基于SSH连接的Jenkins代理Docker镜像,支持Jenkins分布式构建。镜像兼容SSH Build Agents等插件,提供多种JDK版本和操作系统配置。用户可灵活运行、扩展和定制镜像。项目文档详细介绍了镜像使用方法、构建过程和测试流程,便于开发者理解和贡献。

JenkinsDockerSSH持续集成容器化Github开源项目

Docker image for Jenkins agents connected over SSH

Join the chat at https://gitter.im/jenkinsci/docker GitHub stars Docker Pulls GitHub release

A Jenkins agent image which allows using SSH to establish the connection. It can be used together with the SSH Build Agents plugin or other similar plugins.

See Jenkins Distributed builds for more info.

Running

Running with the SSH Build Agents plugin

To run a Docker container

docker run -d --rm --name=agent --publish 2200:22 -e "JENKINS_AGENT_SSH_PUBKEY=<public_key>" jenkins/ssh-agent
  • -d: To start a container in detached mode, use the -d option. Containers started in detached mode exit when the root process used to run the container exits, unless you also specify the --rm option.
  • --rm: If you use -d with --rm, the container is removed when it exits or when the daemon exits, whichever happens first.
  • --name: Assigns a name to the container. If you do not specify a name, Docker generates a random name.
  • --publish 2200:22: Publishes the host port 2200 to the agent container port 22 (SSH) to allow connection from the host with ssh jenkins@localhost -p 2200

Please note none of these options are mandatory, they are just examples.

You will then be able to connect this agent using the SSH Build Agents plugin as "jenkins" with the matching private key.

When using the Linux image, you have to set the value of the Remote root directory to /home/jenkins/agent in the agent configuration UI.

Remote root directory with a Linux agent

When using the Windows image, you have to set the value of the Remote root directory to C:/Users/jenkins/Work in the agent configuration UI.

Remote root directory with a Windows agent

If you intend to use another directory than /home/jenkins/agent under Linux or C:/Users/jenkins/Work under Windows, don't forget to add it as a data volume.

docker run -v docker-volume-for-jenkins-ssh-agent:/home/jenkins/agent:rw jenkins/ssh-agent "<public key>"

How to use this image with Docker Plugin

To use this image with Docker Plugin, you need to pass the public SSH key using environment variable JENKINS_AGENT_SSH_PUBKEY and not as a startup argument.

In Environment field of the Docker Template (advanced section), just add:

JENKINS_AGENT_SSH_PUBKEY=<YOUR PUBLIC SSH KEY HERE>

Don't put quotes around the public key.

Please note that you have to set the value of the Remote File System Root to /home/jenkins/agent in the Docker Agent Template configuration UI.

Remote File System Root

If you intend to use another directory than /home/jenkins/agent, don't forget to add it as a data volume.

Docker Volumes mounts

You should be all set.

Extending the image

Should you need to extend the image, you could use something along those lines:

FROM jenkins/ssh-agent:debian-jdk17 as ssh-agent # [...] COPY --chown=jenkins mykey "${JENKINS_AGENT_HOME}"/.ssh/mykey # [...]

Configurations

The image has several supported configurations, which can be accessed via the following tags:

${IMAGE_VERSION} can be found on the releases page.

  • latest, latest-jdk11, jdk11, latest-bookworm-jdk11, bookworm-jdk11, latest-debian-jdk11, debian-jdk11, ${IMAGE_VERSION}, ${IMAGE_VERSION}-jdk11, (Dockerfile)
  • latest-jdk17, jdk17, latest-bookworm-jdk17, bookworm-jdk17, latest-debian-jdk17, debian-jdk17, ${IMAGE_VERSION}-jdk17, (Dockerfile)
  • nanoserver-1809, nanoserver-ltsc2019, nanoserver-1809-jdk11, nanoserver-ltsc2019-jdk11, ${IMAGE_VERSION}-nanoserver-1809, ${IMAGE_VERSION}-nanoserver-ltsc2019, ${IMAGE_VERSION}-nanoserver-1809-jdk11, ${IMAGE_VERSION}-nanoserver-ltsc2019-jdk11 (Dockerfile)
  • windowsservercore-1809, windowsservercore-ltsc2019, windowsservercore-1809-jdk11, windowsservercore-ltsc2019-jdk11, ${IMAGE_VERSION}-windowsservercore-1809, ${IMAGE_VERSION}-windowsservercore-ltsc2019, ${IMAGE_VERSION}-windowsservercore-1809-jdk11, ${IMAGE_VERSION}-windowsservercore-ltsc2019-jdk11 (Dockerfile)

Building instructions

Pre-requisites

Should you want to build this image on your machine (before submitting a pull request for example), please have a look at the pre-requisites:

Building

Target images

If you want to see the target images that will be built, you can issue the following command:

make list alpine_jdk11 alpine_jdk17 debian_jdk11 debian_jdk17

Building a specific image

If you want to build a specific image, you can issue the following command:

make build-<OS>_<JDK_VERSION>

That would give for JDK 17 on Alpine Linux:

make build-alpine_jdk17

Building images supported by your current architecture

Then, you can build the images supported by your current architecture by running:

make build

Testing all images

If you want to test these images, you can run:

make test

Testing a specific image

If you want to test a specific image, you can run:

make test-<OS>_<JDK_VERSION>

That would give for JDK 17 on Alpine Linux:

make test-alpine_jdk17

Building all images

You can build all images (even those unsupported by your current architecture) by running:

make every-build

Other make targets

show gives us a detailed view of the images that will be built, with the tags, platforms, and Dockerfiles.

make show { "group": { "default": { "targets": [ "alpine_jdk17", "alpine_jdk11", "debian_jdk11", "debian_jdk17", ] } }, "target": { "alpine_jdk11": { "context": ".", "dockerfile": "alpine/Dockerfile", "tags": [ "docker.io/jenkins/ssh-agent:alpine-jdk11", "docker.io/jenkins/ssh-agent:latest-alpine-jdk11" ], "platforms": [ "linux/amd64" ], "output": [ "type=docker" ] }, [...]

bats is a dependency target. It will update the bats submodule and run the tests.

make bats make: 'bats' is up to date.

publish allows the publication of all images targeted by 'linux' to a registry.

docker-init is dedicated to Jenkins infrastructure for initializing docker and isn't required in other contexts.

Building and testing on Windows

Building all images

Run .\build.ps1 to launch the build of the images corresponding to the "windows" target of docker-bake.hcl.

Internally, the first time you'll run this script and if there is no build-windows.yaml file in your repository, it will use a combination of docker buildx bake and yq to generate a build-windows.yaml docker compose file containing all Windows image definitions from docker-bake.hcl. Then it will run docker compose on this file to build these images.

You can modify this docker compose file as you want, then rerun .\build.ps1. It won't regenerate the docker compose file from docker-bake.hcl unless you add the -OverwriteDockerComposeFile build.ps1 parameter: .\build.ps1 -OverwriteDockerComposeFile.

Note: you can generate this docker compose file from docker-bake.hcl yourself with the following command (require docker buildx and yq):

# - Use docker buildx bake to output image definitions from the "windows" bake target # - Convert with yq to the format expected by docker compose # - Store the result in the docker compose file $ docker buildx bake --progress=plain --file=docker-bake.hcl windows --print ` | yq --prettyPrint '.target[] | del(.output) | {(. | key): {\"image\": .tags[0], \"build\": .}}' | yq '{\"services\": .}' ` | Out-File -FilePath build-windows.yaml

Note that you don't need build.ps1 to build (or to publish) your images from this docker compose file, you can use docker compose --file=build-windows.yaml build.

Testing all images

Run .\build.ps1 test if you also want to run the tests harness suit.

Run .\build.ps1 test -TestsDebug 'debug' to also get commands & stderr of tests, displayed on top of them. You can set it to 'verbose' to also get stdout of every test command.

Note that instead of passing -TestsDebug parameter to build.ps1, you can set the $env:TESTS_DEBUG environment variable to the desired value.

Also note that contrary to the Linux part, you have to build the images before testing them.

Dry run

Add the -DryRun parameter to print out any build, publish or tests commands instead of executing them: .\build.ps1 test -DryRun

Building and testing a specific image

You can build (and test) only one image type by setting -ImageType to a combination of Windows flavors ("nanoserver" & "windowsservercore") and Windows versions ("1809", "ltsc2019", "ltsc2022").

Ex: .\build.ps1 -ImageType 'nanoserver-ltsc2019'

Warning: trying to build windowsservercore-1809 will fail as there is no corresponding image from Microsoft.

Changelog

See GitHub Releases. Note that the changelogs and release tags were introduced in Dec 2019, and there are no entries for previous releases. Please consult with the commit history if needed.

编辑推荐精选

Trae

Trae

字节跳动发布的AI编程神器IDE

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

openai-agents-python

openai-agents-python

OpenAI Agents SDK,助力开发者便捷使用 OpenAI 相关功能。

openai-agents-python 是 OpenAI 推出的一款强大 Python SDK,它为开发者提供了与 OpenAI 模型交互的高效工具,支持工具调用、结果处理、追踪等功能,涵盖多种应用场景,如研究助手、财务研究等,能显著提升开发效率,让开发者更轻松地利用 OpenAI 的技术优势。

下拉加载更多