openshift / jenkins-plugin

Apache License 2.0
81 stars 50 forks source link

openshiftBuild should support binary build type. #165

Closed etsauer closed 6 years ago

etsauer commented 6 years ago

Many pipelines use openshift to simply deploy a jar/war/ear from the workspace to an s2i-enabled image. It would be nice to be able to use the pipeline plugin methods to do this rather than have to drop into the shell for a simple oc start-build foo --from-file/--from-dir command.

gabemontero commented 6 years ago

Thanks for the interest @etsauer , but we are not taking on new enhancements for this plugin, as https://github.com/openshift/jenkins-client-plugin is now our strategic direction for openshift/jenkins integration from pipelines.

You can in fact perform binary builds with the openshift.startBuild(...) directive with that plugin.

glenns1 commented 5 years ago

Thanks @gabemontero - I know this is close, but it is not clear how to push a binary image (--from-file) through the openshift Jenkins plugin using 'openshift.startBuild(...)'. please elaborate.

gabemontero commented 5 years ago

@glenns1 use existing pipeline function like https://jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#code-findfiles-code-find-files-in-the-workspace to find the binary file in your pipeline's workspace to find the fully qualified path of your binary file. Supply the right path as the value for --from-file in the args you pass to startbuild

glenns1 commented 5 years ago

@gabemontero Thanks for this feedback. I tried running that command, but not clear on the syntax and was failing. if you have an example with the --from-file option for a start build equivalent please?

gabemontero commented 5 years ago

how about providing exactly what you tried @glenns1 and I'll modify it as needed

glenns1 commented 5 years ago

Thanks @gabemontero Is there a way to take this offline?

This is what I use for pipeline script:

node(label 'ocpmaster' { stage 'gatherFiles' def files = findFiles(glob: '*/.jar') echo """${files[0].name} ${files[0].path} ${files[0].directory} ${files[0].length} ${files[0].lastModified}""" }

glenns1 commented 5 years ago

hi @gabemontero did you get a chance to look at this? can we take it offline? thanks

gabemontero commented 5 years ago

@glenns1 how did you take the file gathering above and supply it to the openshift.startBuild(...) call?

Can you supply that syntax as well, and any error logs that may have occurred when you try it.

Lastly, are you famiilar with binary builds in general ... are you able to do them from the command line via the oc cli? See https://docs.okd.io/latest/dev_guide/builds/build_inputs.html#binary-source if you are unfamiliar.

Also, sorry, but I want to keep the discussion here, for other's benefits, including some new devs for the client plugin function.

@waveywaves fyi ^^

glenns1 commented 5 years ago

Hi @gabemontero

I am familiar with and using the binary builds. I currently use this: oc start-build my-openjdk-app --from-file=/home/executable-sample-jar.jar

But I wish to run it in a Jenkins pipeline: openshiftBuild(namespace: 'development', buildConfig: 'my-openjdk-app', showBuildLogs: 'true')

Therefore, I require the --from-file option, which is how I got to needing: def files = findFiles(glob: '*/.jar') echo """${files[0].name} ${files[0].path} ${files[0].directory} ${files[0].length} ${files[0].lastModified}"""

The error from running this stage: [Pipeline] stage (definefiles) Using the ‘stage’ step without a block argument is deprecated Entering stage definefiles Proceeding [Pipeline] findFiles [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline /var/jenkins/workspace/testpipeline does not exist. at org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(AbstractFileSet.java:483) at hudson.FilePath.glob(FilePath.java:1759) at hudson.FilePath.access$1700(FilePath.java:196)

Thanks

gabemontero commented 5 years ago

@glenns1 ok we may not be on the same page here.

Earlier you mentioned openshift.startBuild(..) from the jenkins-client plugin. But your last comment mentions openshiftBuild which is for this plugin. This plugin is deprecated in favor of https://github.com/openshift/jenkins-client-plugin

We are not adding support for binary builds in this plugin.

Did you try it with the client-plugin? Can you provide the pipeline code and full log results when you tried it using the client plugin?