2

I have a template that I have uploaded to openshift.

$ oc get templates | grep jenkins
jenkins-mycompany  Jenkins persistent image 9 (all set) 9 

When I get the template, you can see the parameters that are set:

$ oc get template jenkins-mycompany -o json

...

{
        "description": "Name of the ImageStreamTag to be used for the Jenkins image.",
        "displayName": "Jenkins ImageStreamTag",
        "name": "JENKINS_IMAGE_STREAM_TAG",
        "value": "jenkins-mycompany:2.0.0-18"
    }

I am creating a CI process to build a new Jenkins image and update the template that is uploaded into OpenShift.

I want all params set...

I have tried

  1. oc process -f deploy.yml --param-file=my-param-file | oc create -f-
  2. cat mydeploy.json | oc create -f-

The only way I can get this to work is to do an oc delete templates jenkins-mycompany and then oc create -f deploy.yml.

I want to just patch the value of that one parameter so when I build 2.0.0-19, I just patch the template.

Chris Bolton
  • 2,162
  • 4
  • 36
  • 75
  • Why not making the "jenkins-mycompany:2.0.0-18" a parameter of the template, that needs to be provided when processing it? – ptrk Dec 20 '18 at 10:42
  • @ptrk i would prefer the params to be set so my consumers just need to process the default template and it works out of the box. the consumers can override params. – Chris Bolton Jan 02 '19 at 16:04
  • There are two levels of providing params. One is the template itself, so you can have a default and optionally override it when processing the template. Then there's the DeploymentConfig params you can override again. So you can have the consumers process the default or override. – ptrk Jan 08 '19 at 13:20

1 Answers1

0

Openshift CLI Reference

You want to use the patch command like so:

oc patch <object_type> <object_name> -p <changes>

For example,

oc patch template jenkins-mycompany -p '{"spec":{"unschedulable":true}}'

Chris Bolton
  • 2,162
  • 4
  • 36
  • 75
Ciaodown
  • 529
  • 5
  • 15