英文:
Using something similar to lockable resource in Jenkins on GitLab
问题
我们的构建流水线主要涉及两个阶段:构建和测试。在测试阶段,流水线与物理微控制器板通信。不应同时被多个任务并发使用,为了保证这一点,我们使用了 Jenkins Lockable Resource 插件。
我们现在正处于将这些 Jenkins 任务转换为 GitLab CICD 的过程中,但我们没有找到GitLab提供的类似功能。尽管不太直接,我们认为唯一的替代方式是将每个Runner与一个测试板强制绑定。如果有人知道如何在GitLab中实现这一点,那将非常好。谢谢!
英文:
Our build pipeline involves mainly two stages build and test. During the test stage pipeline communicates with physical microcontroller board. It should not used concurrently by multiple jobs and to preserve this we are using jenkins lockable resource plugin.
We are now in the middle of transforming these Jenkins jobs to GitLab CICD and did not find any such functionality provided by GitLab. Though not straight forward, the only alternative way we thought we can achieve this was force couple each runner with one test board. It would be great if anyone can share their thoughts if they know how to achieve this in GitLab. Thanks!
答案1
得分: 1
Sure, here is the translated text:
> 虽然不太直接,但我们认为唯一的替代方法是强制将每个运行者与一个测试板进行耦合。
如果您的资源(微控制器板)可能在不同的GitLab项目中使用,这可能是最好的方法。
如果您只关心在同一个GitLab项目内的作业/流水线之间进行资源锁定,您可以使用资源组来应用锁定机制,以确保只有一个作业可以在任何时候获取资源锁定。
需要锁定资源的作业将等待资源锁被释放(持有锁的作业完成)后才会启动。根据文档:
> 使用resource_group
创建一个资源组,确保作业在同一项目的不同流水线中是互斥的。
>
> 例如,如果属于同一资源组的多个作业同时排队,只有一个作业会启动。其他作业会等待直到resource_group
空闲。
>
> 资源组的行为类似于其他编程语言中的信号量。
>
> 您可以在每个环境中定义多个资源组。例如,在部署到物理设备时,您可能有多个物理设备。每个设备都可以进行部署,但每次只能在一个设备上进行部署。
英文:
> Though not straight forward, the only alternative way we thought we can achieve this was force couple each runner with one test board
This is probably the best approach if your resource (the microcontroller board) may be used across different GitLab projects.
If you only care about resource locking across jobs/pipelines within the same GitLab project, you can use resource groups to apply locking mechanisms to ensure only one job can acquire the resource lock at any time.
Jobs needing a locked resource will wait for the resource lock to be released (the job holding the lock completes) before they will start. From the docs:
> Use resource_group
to create a resource group that ensures a job is mutually exclusive across different pipelines for the same project.
>
> For example, if multiple jobs that belong to the same resource group are queued simultaneously, only one of the jobs starts. The other jobs wait until the resource_group
is free.
>
> Resource groups behave similar to semaphores in other programming languages.
>
> You can define multiple resource groups per environment. For example, when deploying to physical devices, you might have multiple physical devices. Each device can be deployed to, but only one deployment can occur per device at any given time.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论