Giter VIP home page Giter VIP logo

Comments (8)

jcpowermac avatar jcpowermac commented on August 18, 2024

So my observation is incorrect. The problem is the arguments to tag need to be quoted. Should the plugin handle that or do I need to in the pipeline?

Example

 openshift.raw("tag", 
                                "\"${openshift.project()}/${env.IMAGE_STREAM_NAME}:${env.GIT_COMMIT}\"", 
                                "\"${openshift.project()}/${env.IMAGE_STREAM_NAME}:${env.VERSION}\"")

from jenkins-client-plugin.

gabemontero avatar gabemontero commented on August 18, 2024

Yeah, I believe it has something to do with the tag args, but the "need to be quoted" doesn't seem right ... perhaps Jenkins is doing something unexpected during the env var substitution, or the last env var has a new line, and the extra quoting somehow mitigates that.

By comparison, I tried this simpler but analogous script:

openshift.withCluster("asdf") {
    istag = openshift.selector('istag')
                                
    openshift.verbose()
    openshift.tag("nodejs-010-centos7:latest", "nodejs-010-centos7:foo")
}

And it puts the insecure flag on the same line:

[Pipeline] _OcAction
Verbose sub-step output:
	Command> oc tag nodejs-010-centos7:latest nodejs-010-centos7:foo --insecure-skip-tls-verify --server=https://172.30.0.1:443 --namespace=myproject --loglevel=8 --token=XXXXX 
	Status> 0
	StdOut>Tag nodejs-010-centos7:foo set to nodejs-010-centos7@sha256:bd971b467b08b8dbbbfee26bad80dcaa0110b184e0a8dd6c1b0460a6d6f5d332.

And when I artificially set up some env vars and reference them:

openshift.withCluster("asdf") {
    istag = openshift.selector('istag')
                                
    script {
        env.TAG1 = 'nodejs-010-centos7:latest'
        env.TAG2 = 'nodejs-010-centos7:foo'
    }
    openshift.verbose()
    openshift.tag("${env.TAG1}", "${env.TAG2}")
}

it is still single line:

[Pipeline] _OcAction
Verbose sub-step output:
	Command> oc tag nodejs-010-centos7:latest nodejs-010-centos7:foo --insecure-skip-tls-verify --server=https://172.30.0.1:443 --namespace=myproject --loglevel=8 --token=XXXXX 
	Status> 0
	StdOut>Tag nodejs-010-centos7:foo set to nodejs-010-centos7@sha256:bd971b467b08b8dbbbfee26bad80dcaa0110b184e0a8dd6c1b0460a6d6f5d332.

@jcpowermac - Can you re-run your test, where prior to the tag operation you attempt to echo your two params on a single line, with some text afterward to confirm, and see if it all displays on 1 line or multiple lines? Again I'm wondering if the specific env var somehow has a new line in it.

thanks

from jenkins-client-plugin.

gabemontero avatar gabemontero commented on August 18, 2024

If it is something related to new line chars, perhaps the plugin should help the user and strip all "\n" and "\r" from supplied args. But short term, certainly that might be something to pursue in the script.

from jenkins-client-plugin.

jcpowermac avatar jcpowermac commented on August 18, 2024

@gabemontero after I put this issue in I found out that the env.VERSION = readFile('app/VERSION') had a newline character. I added trim() yesterday and retested this morning without quotes and its perfectly fine. Interesting that the openshift allowed a newline character in an object name. I had to use skoepo inspect to find it. Thanks and sorry about the confusion.

from jenkins-client-plugin.

gabemontero avatar gabemontero commented on August 18, 2024

thanks for the confirmation @jcpowermac

glad it is sorted out for you short term

and as I mentioned previously, the plugin probably should look at trimming all args; we did that with the legacy plugin

from jenkins-client-plugin.

gabemontero avatar gabemontero commented on August 18, 2024

btw, I was curious about withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: "registry-api", usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']])

what you got going on there exactly ?

from jenkins-client-plugin.

jcpowermac avatar jcpowermac commented on August 18, 2024

@gabemontero the PASSWORD has a service account token for a remote openshift cluster. I was eventually going to move it to using:

environment {
   mycred = credentials('foo')
}

We are syncing the OpenShift secrets to Jenkins via a library until the plugin does that.

from jenkins-client-plugin.

gabemontero avatar gabemontero commented on August 18, 2024

from jenkins-client-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.