Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jenkins Kubernetes插件:声明性管道和pod模板继承_Jenkins_Kubernetes - Fatal编程技术网

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

Jenkins Kubernetes插件:声明性管道和pod模板继承,jenkins,kubernetes,Jenkins,Kubernetes,Jenkins Kubernetes插件的文档说明: 与脚本化k8s模板不同,声明性模板不从父模板继承。如有必要,您需要显式声明继承。 不幸的是,没有关于如何显式声明从构建的主模板继承的示例。我试着使用标签,但是继承似乎被忽略了 def parentLabel = "my-project-${UUID.randomUUID().toString()}" pipeline { agent { kubernetes { label parentLa

Jenkins Kubernetes插件的文档说明:

与脚本化k8s模板不同,声明性模板不从父模板继承。如有必要,您需要显式声明继承。

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

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}
                    """
                }
            }
        }
    }
}

如何/通过什么样的模板名称引用stage agent声明中
inheritFrom
语句中管道顶部声明的模板,以实际明确定义继承

你有没有找到解决方法?没有,我们只是完全定义了stage agent模板,没有任何继承。这也是我提出的解决方案。真可惜。尽管如此,还是要感谢你的回应。