[JIRA] (JENKINS-51255) Kubernetes plugin declarative pipeline can't use readFile to read yaml file

118 views
Skip to first unread message

kev.carrasco@gmail.com (JIRA)

unread,
May 10, 2018, 6:03:02 PM5/10/18
to jenkinsc...@googlegroups.com
Kevin Carrasco created an issue
 
Jenkins / Bug JENKINS-51255
Kubernetes plugin declarative pipeline can't use readFile to read yaml file
Issue Type: Bug Bug
Assignee: Carlos Sanchez
Components: kubernetes-plugin
Created: 2018-05-10 22:02
Priority: Minor Minor
Reporter: Kevin Carrasco

Using the following settings declarative pipeline:

pipeline {
    agent {
        kubernetes {
            cloud 'OpenShift'
            label 'jenkins-agent-pod'
            yaml readFile('k8s-podspec.yaml')
        }
    }
...

 

Results in the following error from Jenkins:

Running in Durability level: MAX_SURVIVABILITY
[Pipeline] readFile
Required context class hudson.FilePath is missing
Perhaps you forgot to surround the code with a step that provides this, such as: node
[Pipeline] End of Pipeline

 

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

o.v.nenashev@gmail.com (JIRA)

unread,
May 14, 2018, 4:03:02 AM5/14/18
to jenkinsc...@googlegroups.com
Oleg Nenashev updated an issue
Change By: Oleg Nenashev
Component/s: pipeline
Component/s: pipeline-model-definition-plugin

o.v.nenashev@gmail.com (JIRA)

unread,
May 14, 2018, 4:03:02 AM5/14/18
to jenkinsc...@googlegroups.com
Oleg Nenashev commented on Bug JENKINS-51255
 
Re: Kubernetes plugin declarative pipeline can't use readFile to read yaml file

Not a K8s plugin defect IMHO. In Declarative the workspace is not mapped before creating the first agent, hence readFile() cannot work in this section AFAIK

From where do you expect to read it? From master? or from the repo?

andrew.bayer@gmail.com (JIRA)

unread,
May 14, 2018, 11:37:02 AM5/14/18
to jenkinsc...@googlegroups.com

Oleg Nenashev is correct - we should probably add something to the kubernetes plugin's Declarative agent setup for doing a readTrusted of a YAML file for this sort of use case.

kev.carrasco@gmail.com (JIRA)

unread,
May 14, 2018, 1:52:02 PM5/14/18
to jenkinsc...@googlegroups.com

o.v.nenashev@gmail.com (JIRA)

unread,
May 14, 2018, 1:54:02 PM5/14/18
to jenkinsc...@googlegroups.com

kev.carrasco@gmail.com (JIRA)

unread,
May 14, 2018, 1:54:02 PM5/14/18
to jenkinsc...@googlegroups.com
Kevin Carrasco edited a comment on Bug JENKINS-51255
 
Re: Kubernetes plugin declarative pipeline can't use readFile to read yaml file
[~oleg_nenashev] I expect to read k8s-podspec.yaml from the repository.   We would like the yaml file to be part of the source code on a separate file. For now we're including the yaml contents in the Jenkinsfile.

o.v.nenashev@gmail.com (JIRA)

unread,
May 14, 2018, 2:02:03 PM5/14/18
to jenkinsc...@googlegroups.com

o.v.nenashev@gmail.com (JIRA)

unread,
May 14, 2018, 2:02:05 PM5/14/18
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Aug 8, 2018, 10:49:01 AM8/8/18
to jenkinsc...@googlegroups.com
Andrew Bayer updated New Feature JENKINS-51255
 

We added a new yamlFile option as of Kubernetes plugin 1.10.0 that does what you're looking for.

Change By: Andrew Bayer
Status: Open Fixed but Unreleased
Resolution: Duplicate
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)
Reply all
Reply to author
Forward
0 new messages