0

Currently in my jenkins setup I have 1 master and 2 nodes. One node has jdk 7 and another node has jdk8. Now I want to execute pipelines under jdk8 but not under jdk7 as I have migrated the application from jdk7 to 8.

If I run the pipelines only on the node where jdk8 is installed will work?? OR do I need to do the changes in the pipeline as such as adding new jdk8 version as env variable in the package stage in the pipeline?

just I want to compile the code under jdk8 instead of 7 in jenkins?

Monty
  • 11
  • 2
  • Label your nodes w/ either jdk8 or jdk7, then edit the pipeline to use [`agent`](https://www.jenkins.io/doc/book/pipeline/syntax/#agent) or `node`, ie: `agent { label 'my-defined-label' }`. Also use [`tools`](https://www.jenkins.io/doc/book/pipeline/syntax/#tools) [Pipeline syntax](https://www.jenkins.io/doc/book/pipeline/syntax/) – Ian W Aug 19 '21 at 06:59
  • labelled the node and added the same in the pipeline with jdk8 node and completed the pipeline execution. Is it sufficient to say that the java compilation is being updated with jdk8 on jenkins for a specific pipeline?? Is my understanding correct? – Monty Aug 19 '21 at 07:14
  • You'd have to update your post w/your original and revised pipeline to confirm, but constraining a stage (or entire pipeline) with a label means it will execute on a node w/matching label only. Of course, this assume the right java is on the path or you used the `tools` syntax. You can verify jar using [jarcheck](https://www.mindprod.com/products1.html#JARCHECK) or by unpacking the jar and using unix `file` cmd. Q [answered here](https://stackoverflow.com/questions/47895668/how-to-select-multiple-jdk-version-in-declarative-pipeline-jenkins) – Ian W Aug 19 '21 at 07:27
  • Does this answer your question? [How to select multiple JDK version in declarative pipeline Jenkins](https://stackoverflow.com/questions/47895668/how-to-select-multiple-jdk-version-in-declarative-pipeline-jenkins) – Ian W Aug 19 '21 at 07:32
  • node('slave-jdk8'){ – Monty Aug 19 '21 at 08:25

0 Answers0