首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从存储库读取openshift模板时出现问题(Bitbucket)

从存储库读取openshift模板时出现问题(Bitbucket)
EN

Stack Overflow用户
提问于 2020-07-07 00:26:43
回答 1查看 112关注 0票数 0

我有一个jenkins管道脚本来创建一个应用程序使用openshift模板放置在存储库(Bit Bucket)。但是,我每次都会得到下面提到的错误。

注意:我也在Jenkins中配置了凭证。

版本openshift v3.11.200 kubernetes v1.11.0+d4cacc0

重现PipeLine脚本的步骤:

代码语言:javascript
复制
// path of the template to use
def templatePath = 'https://xxxx/git/users/pdeb/repos/mashery-local/raw/acs/tml-acs-template.json'
// name of the template that will be created
def templateName = 'mashery-local'
// NOTE, the "pipeline" directive/closure from the declarative pipeline syntax needs to include, or be nested outside,
// and "openshift" directive/closure from the OpenShift Client Plugin for Jenkins.  Otherwise, the declarative pipeline engine
// will not be fully engaged.
pipeline {

    agent any

    stages {
        stage('preamble') {
            steps {
                script {
                    openshift.withCluster() {
                        openshift.withProject() {
                            echo "Using project: ${openshift.project()}"
                        }
                    }
                }
            }
        }
        stage('cleanup') {
            steps {
                script {
                    openshift.withCluster() {
                        openshift.withProject() {
                            // delete everything with this template label
                            openshift.selector("all", [ template : templateName ]).delete()
                            // delete any secrets with this template label
                            if (openshift.selector("secrets", templateName).exists()) {
                                openshift.selector("secrets", templateName).delete()
                            }
                        }
                    }
                } // script
            } // steps
        } // stage
        stage('create') {
            steps {
                script {
                    openshift.withCluster() {
                        openshift.withProject() {
                            // create a new application from the templatePath
                            openshift.newApp(templatePath)
                        }
                    }
                } // script
            } // steps
        } // stage
    } // stages
} // pipeline

当前结果:

代码语言:javascript
复制
*ERROR: new-app returned an error;
{reference={}, err=error: unable to load template file "https://rndwww.nce.amadeus.net/git/users/pdeb/repos/mashery-local-on-acs/raw/acs/tml-acs-template.json": unable to decode "https://rndwww.nce.amadeus.net/git/users/pdeb/repos/mashery-local-on-acs/raw/acs/tml-acs-template.json": couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }
error: git ls-remote failed with: fatal: https://rndwww.nce.amadeus.net/git/users/pdeb/repos/mashery-local-on-acs/raw/acs/tml-acs-template.json/info/refs not valid: is this a git repository?;  local file access failed with: stat https://rndwww.nce.amadeus.net/git/users/pdeb/repos/mashery-local-on-acs/raw/acs/tml-acs-template.json: no such file or directory
error: unable to locate any images in image streams, templates loaded in accessible projects, template files, local docker images with name "https://rndwww.nce.amadeus.net/git/users/pdeb/repos/mashery-local-on-acs/raw/acs/tml-acs-template.json"
Argument 'https://rndwww.nce.amadeus.net/git/users/pdeb/repos/mashery-local-on-acs/raw/acs/tml-acs-template.json' was classified as an image, image~source, or loaded template reference.
The 'oc new-app' command will match arguments to the following types:
  1. Images tagged into image streams in the current project or the 'openshift' project
     - if you don't specify a tag, we'll add ':latest'
  2. Images in the Docker Hub, on remote registries, or on the local Docker engine
  3. Templates in the current project or the 'openshift' project
  4. Git repository URLs or local paths that point to Git repositories
--allow-missing-images can be used to point to an image that does not exist yet.
See 'oc new-app -h' for examples., verb=new-app, cmd=oc --server=https://10.224.0.1:443 --certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt --namespace=lhmdw-tml-dev --token=XXXXX new-app https://rndwww.nce.amadeus.net/git/users/pdeb/repos/mashery-local-on-acs/raw/acs/tml-acs-template.json -o=json , out=, status=1}
Finished: FAILURE*

预期结果:成功运行模板。

EN

回答 1

Stack Overflow用户

发布于 2020-07-07 14:18:14

以下错误消息表明您的模板文件的格式不正确:

代码语言:javascript
复制
json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }

因此,您应该修复模板tml-acs-template.json的内容,因为该文件目前不能使用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62760385

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档