Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

构建失败,jenkins控制台报错显示:Failed to parse yaml #194

Open
Linwenqiang-git opened this issue May 9, 2023 · 14 comments · Fixed by #196
Open

构建失败,jenkins控制台报错显示:Failed to parse yaml #194

Linwenqiang-git opened this issue May 9, 2023 · 14 comments · Fixed by #196
Assignees
Labels
💊 bug Something isn't working

Comments

@Linwenqiang-git
Copy link

运行环境

  • 应用版本:
    • atomci-frontend: 基于v2.0-alpha分支本地运行
    • atomci: 基于v2.0-alpha分支本地运行
  • Kubernetes: v1.21.6

问题描述

按照如下步骤,环境均已配置完成:

系统基础配置
->服务集成(K8s、harbor、jenkins)
->编译环境
->代码源集成(github、gitee、gitlab)

创建应用(具体的服务)
-> 选择代码源(系统配置的代码源)
-> 仓库路径
-> 编译环境

创建项目
-> 项目环境(dev、test、online)
-> 项目流程(构建、部署、人工卡点)
-> 关联代码仓库(选择已创建好的应用)
-> 应用编排
-> 创建流水线
-> 选择流程
-> 选择分支
-> 构建部署
-> jenkins拉取构建服务
-> 部署到K8s
jenkins与K8s可正确连接,且K8s相关插件正确安装
测试过两个场景,报错一致:
第一种:编排文件按照视频用官网默认的;
第二种:不填写编排文件;
构建均失败,jenkins控制台报错如下:
Started by user administrators
[Pipeline] Start of Pipeline
[Pipeline] podTemplate
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
hudson.remoting.ProxyException: io.fabric8.kubernetes.client.KubernetesClientException: name not specified for an operation requiring one.
at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.requireFromServer(BaseOperation.java:182)
at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.get(BaseOperation.java:142)
at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.get(BaseOperation.java:93)
at org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.parseFromYaml(PodTemplateUtils.java:610)
at org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.validateYamlContainerNames(PodTemplateUtils.java:639)
at org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.validateYamlContainerNames(PodTemplateUtils.java:629)
at org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution.start(PodTemplateStepExecution.java:145)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:322)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
Caused: hudson.remoting.ProxyException: java.lang.RuntimeException: Failed to parse yaml: "
apiVersion: v1
kind: Pod
metadata:
namespace: devops
spec:
containers:

  • name: jnlp
    image: colynn/jenkins-jnlp-agent:latest
    workingDir: /home/jenkins/agent
    command:
    args:
    tty: true
  • name: kaniko
    image: colynn/kaniko-executor:debug
    workingDir: /home/jenkins/agent
    command:
    • /bin/sh
    • -c
      args:
    • cat
      tty: true
      "
      at org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.parseFromYaml(PodTemplateUtils.java:612)
      at org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.validateYamlContainerNames(PodTemplateUtils.java:639)
      at org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.validateYamlContainerNames(PodTemplateUtils.java:629)
      at org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution.start(PodTemplateStepExecution.java:145)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:322)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196)
      at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
      at org.csanchez.jenkins.plugins.kubernetes.pipeline.KubernetesDeclarativeAgentScript.run(KubernetesDeclarativeAgentScript.groovy:51)
      at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inDeclarativeAgent(ModelInterpreter.groovy:594)
      at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.call(ModelInterpreter.groovy:76)
      at WorkflowScript.run(WorkflowScript:3)
      at cps.transform(Native Method)
      at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:90)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:116)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:85)
      at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
      at com.cloudbees.groovy.cps.Next.step(Next.java:83)
      at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:158)
      at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:152)
      at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136)
      at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275)
      at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:152)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
      at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:187)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:420)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:95)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:330)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:294)
      at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
      at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:750)
      Finished: FAILURE

截图

截图一直上传失败,直接复制了控制台信息

@colynn
Copy link
Member

colynn commented May 9, 2023

添加下『项目流程』包含哪些阶段, 及关联的任务模板的配置

@Linwenqiang-git
Copy link
Author

任务模板采用的系统默认的:应用构建->应用部署->人工卡点
image
目前在第一个阶段,应用构建出现上述问题
image

@Linwenqiang-git
Copy link
Author

image

@colynn
Copy link
Member

colynn commented May 10, 2023

类似下图,你添加下关联应用的编译环境 再试下
image

上图编译环境的来源是这里
image

@Linwenqiang-git
Copy link
Author

类似下图,你添加下关联应用的编译环境 再试下 image

上图编译环境的来源是这里 image

image
不行,还是和上面一样的报错

@colynn
Copy link
Member

colynn commented May 11, 2023

系统管理 下的 选择的编译环境的详情麻烦也发出来看下

@Linwenqiang-git
Copy link
Author

系统管理 下的 选择的编译环境的详情麻烦也发出来看下
都是默认的,没有修改过,麻烦在帮忙看下

image
image
image
image
image

@Linwenqiang-git
Copy link
Author

image
image
找了下源码,K8s Yaml文件的containers节点应该是不允许有重复Key的,
麻烦确认一下这是否是个bug

@colynn
Copy link
Member

colynn commented May 15, 2023

逻辑上 name前有 - 表示为两个条目,

@Linwenqiang-git
Copy link
Author

逻辑上 name前有 - 表示为两个条目,

那会跟K8s插件版本之类的有关系吗?
目前整体流程还没跑通,个人感觉依赖jenkins过重,能否替换成一个具备构建环境的容器来代替?
yaml文件需要自己编写,有些繁琐。
还会持续关注,有机会希望也能够参与进来

@colynn
Copy link
Member

colynn commented May 16, 2023

你可以确认下 对应生成jenkins的 pipeline的代码 是否符合预期,如果符合预期那就有可能是kubernetes插件版本不一致导致的问题,

另外v1.0 重度依赖jenkins, v2.0会引入 argo-workflow

@colynn
Copy link
Member

colynn commented Jun 12, 2023

逻辑上 name前有 - 表示为两个条目,

那会跟K8s插件版本之类的有关系吗? 目前整体流程还没跑通,个人感觉依赖jenkins过重,能否替换成一个具备构建环境的容器来代替? yaml文件需要自己编写,有些繁琐。 还会持续关注,有机会希望也能够参与进来

使用的jenkins是哪个版本?我复现下问题

@Linwenqiang-git
Copy link
Author

image

@colynn colynn added 💊 bug Something isn't working and removed status: needs reproduce labels Jun 19, 2023
@colynn colynn reopened this Jun 25, 2023
@colynn
Copy link
Member

colynn commented Jun 25, 2023

@Linwenqiang-git please confirm if can we close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💊 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants