drone jenkins_将CI从Jenkins转移到Drone

drone jenkins

For a long time, we have been using Jenkins to do the CI without too much thought into it, it’s free, it has a decent UI and seemingly largest community. Look no further, right?

长期以来,我们一直在使用Jenkins进行CI,而没有花太多时间思考,它是免费的,它具有不错的UI和看似最大的社区。 看起来不远吧?

As our codebase gets increasingly complex, the CI process becomes much harder to maintain as each bit of code ask for its own code-sitter, testing, reporting, archiving, etc, especially with our mono-repository architecture which includes various modules written in different languages which need to be built with their own toolchains.

随着我们的代码库变得越来越复杂,CI过程变得越来越难以维护,因为每一位代码都要求其自己的代码发送者,测试,报告,归档等,尤其是在我们的单一存储库体系结构中,该体系结构包含以不同方式编写的各种模块需要使用自己的工具链构建的语言。

动机 (Motivation)

Some pain points off the top of my head:

我的头顶有些疼痛:

1. Environment variables.

1.环境变量。

Many building tasks rely on some environment variables to work properly, whenever I see some errors related to them, I’d check the host machine’s value and Jenkins’s, compare and update them, call task manager to restart the process to have it take effect. Yeah, it reminds me of the good old memory of window 98.

许多构建任务依赖于某些环境变量才能正常工作,每当我看到与它们相关的一些错误时,我都会检查主机的值和Jenkins的值,进行比较和更新,并调用任务管理器以重新启动该过程以使其生效。 是的,这让我想起了Windows 98的美好回忆。

2. Deep navigation

2.深度导航

I know Jenkins is an all-powerful CI product, it makes sense to take some time and effort to pick it up, but it is just frustrating to get lost among all those pages, tabs, and controls.

我知道Jenkins是一种功能强大的CI产品,花一些时间和精力来挑选它是很有意义的,但是迷失在所有这些页面,选项卡和控件中只是令人沮丧。

Image for post

3. Wild plugins

3.野生插件

Each plugin has its own UI components, documentation, and issues, you have to go to the community for help quite often.

每个插件都有其自己的UI组件,文档和问题,您必须经常向社区寻求帮助。

4. Migration of Jenkins configuration

4.迁移Jenkins配置

The CI building process can never be too quick from the developers’ point of view. Before we go for any other alternative products, we tried to move the server to a more powerful PC, but the migration of Jenkin’s configuration did not turn out to be a happy memory.

从开发人员的角度来看,CI的构建过程永远不会太快。 在我们寻求其他替代产品之前,我们曾尝试将服务器移至功能更强大的PC上,但是Jenkin的配置迁移并没有使人高兴。

I’ve tried to look for some export/import button, configuration file, or something like that expecting to do it with some simple clicks, but the reality remains cruel, I followed the instruments from its documentation to back up and restore its home folder before ended up opening two browser tabs and comparing the configuration items I can possibly remember before different errors tease me for under-estimating the task.

我试图寻找一些导出/导入按钮,配置文件或类似的东西,希望通过单击几下即可完成操作,但是现实仍然很残酷,我按照其文档中的说明备份并还原了其主文件夹在结束打开两个浏览器选项卡并比较配置项之前,我可能还记得,在出现不同的错误之前,我会低估任务。

Image for post

5. Parallel execution

5.并行执行

  • how to make some steps run in parallel

    如何使一些步骤并行运行
  • how do I make sure they are actually running in parallel

    我如何确保它们实际上在并行运行

The journey of reading through its documentation and fumbling with the parallelization only make me realize the idea of leaving them running in serial is not that bad.

阅读其文档和弄乱并行化的过程仅使我意识到让它们以串行方式运行的想法还不错。

冒险 (Adventure)

One day we came across Drone which claims to be a CI for busy devs, that sounds cool, I am always very busy, at least act in a very busy way to keep my job during this coronavirus pandemic.

有一天,我们遇到了Drone,它声称是忙碌的开发人员的CI,这听起来很酷,我一直很忙,至少以非常忙碌的方式行事,以在这种冠状病毒大流行期间保持工作。

To begin with, you need some basic understanding of docker or container before jumping on this wagon. The relationship between image and container is sort of like that between executable and process, one is static file while the other is a dynamic running thing. Multiple containers created with the same image are guaranteed to have the exactly same environment (I mean runtime libraries, commands, etc, not the IP, hostname of course).

首先,您需要对docker或容器有一些基本的了解,然后再跳入这辆马车。 映像和容器之间的关系有点像可执行文件和进程之间的关系 ,一个是静态文件,另一个是动态运行的东西。 确保使用同一映像创建的多个容器具有完全相同的环境(我的意思是运行时库,命令等,当然不是IP,主机名)。

Image for post

服务器 (Server)

The whole product is designed around the concept of containers, even the Drone server itself is distributed as a lightweight Docker image. The image is self-contained and does not have any external dependencies.

整个产品都是围绕容器的概念设计的,甚至Drone服务器本身也以轻量级Docker映像的形式分发。 该映像是独立的,没有任何外部依赖性。

The server container can be started with the below command. The container is configured through environment variables.

可以使用以下命令启动服务器容器。 容器是通过环境变量配置的。

Image for post

亚军 (Runner)

Drone runners poll the server for workloads to execute.

无人机赛跑者向服务器轮询要执行的工作负载。

Image for post

管道 (Pipeline)

Image for post
.drone.yml
.drone.yml

It’s just a simple YAML file.

这只是一个简单的YAML文件。

Your configuration could have multiple pipelines, one pipeline has multiple steps which have a sequence of commands to meet your needs.

您的配置可以有多个管道,一个管道有多个步骤,这些步骤包含一系列命令来满足您的需求。

Every step runs in an isolated container created with the image you specified, so you do not have to worry about any environment-related surprises anymore. Drone automatically creates a temporary volume, known as your workspace, where it clones your repository. The workspace is the current working directory for each step in your pipeline.

每个步骤都在使用您指定的映像创建的隔离容器中运行 ,因此您不必再担心与环境有关的任何意外情况。 无人机会自动创建一个临时卷,称为您的工作区 ,在其中克隆您的存储库。 工作空间是管道中每个步骤的当前工作目录。

Pipeline steps are executed sequentially by default. You can optionally describe your build steps as a directed acyclic graph using the depends_on. In the above example we fan-out to execute the first two steps in parallel, and then once complete, we fan-in to execute the final step.

管道步骤默认情况下按顺序执行。 您可以选择使用depends_on将构建步骤描述为有向无环图 。 在上面的示例中,我们扇形展开以并行执行前两个步骤,然后完成后,我们扇形展开以执行最后一步。

With first-class container support and simple parallel syntax, one cannot help but design them to run in parallel to squeeze every drop of juice as possible. You can easily track the running status in the following UI section.

借助一流的容器支持和简单的并行语法,人们不得不将它们设计为并行运行以尽可能地榨取每一滴果汁。 您可以在以下UI部分中轻松跟踪运行状态。

用户界面 (User interface)

Image for post
job running status
作业运行状态

As shown in the image above, there are two pipelines for this commit, js-code-coverage, and CSharp-code-coverage, each has its own steps.

如上图所示,此提交有两个管道,js-code-coverage和CSharp-code-coverage,每个都有其自己的步骤。

dev and test pipelines are running in parallel
dev and test pipelines are running in parallel
开发和测试管道并行运行

本地制作奖金 (Local-build Bonus)

With Jenkins, you cannot know the final result without submitting it to the server and going for at least one cup of coffee, this is not the case anymore with Drone as it comes with a command-line to run a local build. Just imagine how much confidence and proudness it brings to you if you never break anything, I mean, in public.

使用Jenkins,如果不将最终结果提交到服务器并至少喝一杯咖啡,就无法知道最终结果,对于Drone而言,情况已不再如此,因为它附带了用于运行本地版本的命令行 。 试想一下,如果您从未在公开场合破坏任何事物,它将带给您多少信心和自豪感。

So you can make any silly mistake on your own PC and see the result in a relatively short while.

因此,您可以在自己的PC上犯任何愚蠢的错误,并在较短的时间内看到结果。

Image for post
This subcommand executes a local build.
该子命令执行本地构建。

突出 (Highlight)

All environment variables and plugin configuration are saved in the pipeline YAML file which makes it easy to maintain.

所有环境变量和插件配置都保存在管道YAML文件中,这使其易于维护。

Simple enough UIs without too much information

足够简单的用户界面,无需太多信息

Easy parallelization, boosted with the first-class container support

一流的容器支持,轻松并行化

Local build and fast feedback

本地构建和快速反馈

If you are really into programming the CI steps instead of using a declarative YAML file, Drone has something for you too, please check out the Jsonnet, a javascript-like data templating language to generate config data.

如果您真的想编写CI步骤而不是使用声明性的YAML文件,那么Drone也会为您提供一些帮助,请查看Jsonnet (一种类似于javascript的数据模板语言,以生成配置数据)。

已知的问题 (Known issues)

It’s hard to search for a history commit on its dashboard, no search box, no paging.

很难在其仪表板上搜索历史记录提交,没有搜索框,也没有分页。

Image for post

If something wrong happens to either the Drone itself or GitHub, Drone server might miss out on some builds, and users cannot trigger a re-build without calling its API endpoints or checking in some other code.

如果Drone本身或GitHub出了问题,Drone服务器可能会在某些构建中丢失,并且用户无法在不调用其API端点或签入其他代码的情况下触发重新构建。

结论 (Conclusion)

We are very happy with the decision of moving to Drone. It makes CI not as heavy as before and helps us make the full use of container technology, saving more hairs to pull out in the future.

我们对搬到Drone的决定感到非常满意。 它使CI不再像以前那么沉重,并帮助我们充分利用了容器技术,从而节省了更多的毛发供将来使用。

翻译自: https://levelup.gitconnected.com/moving-ci-from-jenkins-to-drone-deaf7b773583

drone jenkins

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值