如何在特定的slave中限制jenkins管道docker代理? [英] How to restrict the jenkins pipeline docker agent in specific slave?

查看:158
本文介绍了如何在特定的slave中限制jenkins管道docker代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我配置了多个jenkins从属服务器,并且只有带有dockerserver的标签才具有docker env,然后如何在此从属服务器中限制jenkins管道docker代理?

I have several jenkins slaves configured and only label with dockerserver has docker env, then how can I restrict the jenkins pipeline docker agent in this slave?

Jenkinsfile下不起作用,stage内部的agent将覆盖已定义的从属dockerserver

Below Jenkinsfile doesn't work, the agent inside stage will overwrite the defined slave dockerserver


pipeline {
    agent { label 'dockerserver' }
    stages {
        stage('Back-end') {
            agent {
                docker { image 'maven:3-alpine' }
            }
            steps {
                sh 'mvn --version'
            }
        }
        stage('Front-end') {
            agent {
                docker { image 'node:7-alpine' }
            }
            steps {
                sh 'node --version'
            }
        }
    }
}

它可能会选择其他不支持docker的奴隶

It may pick other slave which doesn't have docker supported

有什么建议吗?

推荐答案

更多地阅读了指南后,发现它已被声明为

After read the guideline more, noticed it was stated https://jenkins.io/doc/book/pipeline/docker/#specifying-a-docker-label.

应在jenkins全局(系统)配置中进行配置

It shall be configured in the jenkins global(system) configuration

这篇关于如何在特定的slave中限制jenkins管道docker代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆