Use the gradle bootJar instead of jar task and build fails in Jenkins Use the gradle bootJar instead of jar task and build fails in Jenkins jenkins jenkins

Use the gradle bootJar instead of jar task and build fails in Jenkins


Unless you explicitly define the name of the project, Gradle will use the directory name as the project name. On Jenkins, the project directory is called "workspace". artifactoryPublish is presumably using the project name to determine the name of the JAR file to publish. That's not good practice if that's the case.

Anyway, you really should set the name of your project. You won't have to explicitly set baseName on the Jar tasks then. Simply add a settings.gradle file in the root of the project, i.e. next to the build.gradle file, and set its content to:

rootProject.name = "my-project"

That should hopefully fix the problem, although it really depends on what the artifactoryPublish task is doing.


I would want to extend Peter's answer, it is recommended by the authors of Gradle that we should use settings.gradle

Define the root project name in the settings file: The ´rootProject.name´ effectively assigns a name to the build as a whole, which is used in reports like build scans. If the root project name is not set, the name will be the container directory name, which can be unstable (i.e. you can check out your project to any directory).