Jenkins Kubernetes插件:声明式管道和pod模板继承

Jenkins Kubernetes插件的文档指出:

  

与脚本化的k8s模板不同,声明性模板不会从父模板继承。如果需要,您需要显式声明继承。   Plugin Readme

不幸的是,没有如何从构建主模板显式声明继承的示例。我尝试使用标签,但是继承似乎被忽略了。

def parentLabel = "my-project-${UUID.randomUUID().toString()}"

pipeline {
    agent {
        kubernetes {
            label parentLabel
            yamlFile "jenkins-agent.yml"
            // a global template in the cloud configuration
            inheritFrom "docker"
        }
    }
    stages {
        // .. stages using the above agent
        stage( 'Test Container' ) {
            agent {
                kubernetes {
                    label "xcel-spring-stage-${UUID.randomUUID().toString()}"
                    inheritFrom parentLabel
                    yaml """
                    apiVersion: v1
                    kind: pod
                    metadata:
                      namespace: build
                      labels:
                        project: x-celerate-spring-application
                    spec:
                      containers:
                        - name: spring-application
                          # defined in previous stages,skipped for brevity
                          image: ${env.IMAGE_NAME}:${version}.${env.BUILD_NUMber}
                    """
                }
            }
        }
    }
}

如何/可以通过什么模板名称在阶段代理程序声明中的inheritFrom语句中引用在管道顶部声明的模板,以实际地显式定义继承?

wz15116339558 回答:Jenkins Kubernetes插件:声明式管道和pod模板继承

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3160515.html

大家都在问