Issue
-
When creating Liferay PaaS Jenkins builds, you may experience CI/CD pipeline build failures with errors relating to unresolved Gradle dependencies. For example:
> Task :modules:your-module-name:compileJava FAILED [Fatal Error] dependency.pom:1:44: Content is not allowed in prolog. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':modules:your-module-name:compileJava'. > Could not resolve all files for configuration ':modules:your-module-name:compileClasspath'. > Could not resolve dependency:group:name:version. Required by: project :modules:your-module-name > Could not resolve dependency:group:name:version. > Could not parse POM https://repository.url/path/to/dependency.pom > Content is not allowed in prolog.
Environment
- Liferay PaaS
Resolution
This error typically indicates that a dependency file (e.g., a .pom file) is corrupted or incomplete in the Gradle cache of the build agent. To resolve this, you must force Gradle to refresh its dependencies and ignore the existing cache.
-
Add the
--refresh-dependenciesflag to your Gradle build command within your Jenkinsfile (e.g., in thejenkinsfile-before-allorjenkinsfile-before-cloud-buildscripts). For example:./gradlew build --refresh-dependencies -
Execute the CI/CD pipeline build.
Additional Information
After running at least one successful build, the Gradle cache on the build agent will be updated with the correct dependency files. You can remove the flag for subsequent builds.