-
Bug
-
Resolution: Unresolved
-
Undefined
-
None
-
[June-2025] OpenShift Jenkins Client Plugin
-
False
-
-
False
-
-
Description of problem: Jenkins Pipeline scirpt oc plugin thows error while operating on deployment configs
Code snippet
-------------
openshift.withCluster() {
def dc = openshift.withProject(namespaceToDeploy)
serviceVersion = dc.metadata.labels['version']
}
OC command block error response:
--------------------------------
Can't get current Service Version: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'W' with an int value of 87
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
Warning: apps.openshift.io/v1 DeploymentConfig is deprecated in v4.14+, unavailable in v4.10000+
Observation
------------
As per the output listing all deploymentconfigs, first item seems to be wrongly populated causing the issue "Warning: apps/v1 DeploymentConfig is deprecated in v4.14+". It's expecting item starting with deploymentconfig.
Output of list all deployments
-------------------------------
They are named: [Warning: apps/v1 DeploymentConfig is deprecated in v4.14+, unavailable in v4.10000+, deploymentconfig/admin-panel, deploymentconfig/test-service, deploymentconfig/test1-service, deploymentconfig/test2-service, deploymentconfig/test3-service, deploymentconfig/test4-api-service, deploymentconfig/test5-service, deploymentconfig/test6-service]
[Pipeline] echo
Workaround
Prerequisites (if any, like setup, operators/versions):
OpenShift Client
Version1.1.0.424.v829cb_ccf8798
This plugin provides Jenkins pipeline DSL interactions for OpenShift.Jenkins 2.504.2
registry.redhat.io/ocp-tools-4/jenkins-rhel9:v4.16.0ALso tried with latest plugin version as well Version 1.1.0.437
Steps to Reproduce
1) Error executing below script from jenkins pipeline
~~~
openshift.withCluster()
{ def dc = openshift.withProject(namespaceToDeploy) \{ openshift.selector('dc', serviceName).object() } serviceVersion = dc.metadata.labels['version']
}
~~~
2) Issue is only happening with customer's environment, not reproducible at my end with same code.
Actual results: Error
Can't get current Service Version: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'W' with an int value of 87
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
Warning: apps.openshift.io/v1 DeploymentConfig is deprecated in v4.14+, unavailable in v4.10000+
Expected results: It should work fine
Reproducibility (Always/Intermittent/Only Once):
Only is customer's environment when running on a agent build on below dockerfile.
~~~
dockerfile: "FROM openshift/openjdk-21:1.22-1.1752066190\r\n\r\nENV NODE_VERSION=16\r\nENV OC_VERSION=4.16.0\r\n\r\nUSER root\r\n\r\n# Install required packages: Git, OpenShift Client (oc), and Node.js\r\nRUN microdnf --setopt=install_weak_deps=0 --setopt=tsflags=nodocs install -y git \\\r\n && microdnf clean all \\\r\n && curl -L -o /tmp/openshift-client.tar.gz https://mirror.openshift.com/pub/openshift-v4/clients/ocp/$OC_VERSION/openshift-client-linux-$OC_VERSION.tar.gz \\\r\n && tar -xzf /tmp/openshift-client.tar.gz -C /usr/bin \\\r\n && chmod +x /usr/bin/oc \\\r\n && curl -fsSL https://rpm.nodesource.com/setup_$NODE_VERSION.x.rpm | bash - \\\r\n && microdnf install -y nodejs \\\r\n && microdnf install -y wget \\\r\n && microdnf clean all\r\n\r\n# Verify installations\r\nRUN java -version && mvn -version && git --version && oc version && node -v && npm -v\r\n\r\n# Allow everyone access to the folder /home/default/.npm\r\nRUN mkdir -p /home/default/.npm && chmod -R 777 /home/default/.npm\r\n\r\nUSER 185"
~~~
Additional info (Such as Logs, Screenshots, etc):
LOG::
--------
They are named: [Warning: apps/v1 DeploymentConfig is deprecated in v4.14+, unavailable in v4.10000+, deploymentconfig/admin-panel, deploymentconfig/test-service, deploymentconfig/test1-service, deploymentconfig/test2-service, deploymentconfig/test3-service, deploymentconfig/test4-api-service, deploymentconfig/test5-service, deploymentconfig/test6-service]
[Pipeline] echo
dc object detail : selector([name=null],[labels=null],[namelist=[deploymentconfig/test-service]],[projectlist=null])
Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String (com.openshift.jenkins.plugins.OpenShiftDSL$OpenShiftResourceSelector.metadata). Administrators can decide whether to approve or reject this signature.
[Pipeline] echo
Can't get current Service Version: org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String (com.openshift.jenkins.plugins.OpenShiftDSL$OpenShiftResourceSelector.metadata)
[Pipeline] echo
Current Service Version: null