Reputation: 383
I have local copy of Git java code.I want a pipeline job script in Jenkins that can compile and build the code locally and show success or failure .
I need a script which use only Java JDK not the maven (as the source code is developed using eclipse java project).
The os i am using is windows.
pipeline {
agent any
stages {
stage ("build") {
tools {
jdk "jdk-1.8.0_181"
}
steps {
sh 'java -version'
}
}
}}
I am getting below error
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 7: Tool type "jdk" does not have an install of "jdk-1.8.0_181" configured - did you mean "Oracle JDK 8"? @ line 7, column 24. jdk 'jdk-1.8.0_181' ^
1 error
Upvotes: 1
Views: 3396
Reputation: 1699
The tools
section is expecting you to provide the Name to a specific item in your Global Tool Configuration (https://JENKINS_HOME/configureTools, or Manage Jenkins -> Configure Global Tools).
On that page, when you click on the JDK installations... button, it will give you a list of all of the JDKs that are configured. Your pipeline step needs to specify one of the items by Name instead of by Version.
Based on the error hint, I suspect there is one called Oracle JDK 8
; you just need to verify that it is pointing to the appropriate version and update your pipeline section to read:
tools {
jdk "Oracle JDK 8"
}
Reference: The Jenkins Pipeline Syntax page's tools example includes the following note (emphasis theirs):
The tool name must be pre-configured in Jenkins under Manage Jenkins → Global Tool Configuration.
Upvotes: 2