I have been unable to get Azure Pipelines to run the way I am expecting.
The project codebase is in Java, version 8 and is using the JavaFX Library.
I am trying to introduce continuous integration via Azure Pipelines. To do this I decided to use Gradle to manage project dependencies.
Here is the gradle.build file I am using to declare project dependencies.
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* User Manual available at https://docs.gradle.org/6.1.1/userguide/tutorial_java_projects.html
*/
plugins {
// Apply the java plugin to add support for Java
id 'java'
// Apply the application plugin to add support for building a CLI application.
id 'application'
}
repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
// This dependency is used by the application.
implementation 'com.google.guava:guava:28.1-jre'
implementation 'de.dynamicfiles.projects.gradle.plugins:javafx-gradle-plugin:8.8.2'
// Use JUnit Jupiter API for testing.
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
// Use JUnit Jupiter Engine for testing.
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
}
application {
// Define the main class for the application.
mainClassName = 'main.java.application.App'
}
test {
// Use junit platform for unit tests
useJUnitPlatform()
}
This is the error I except when I run my pipeline. This is a run from my computer.
Code\SNR-Project\Anature> ./gradlew build
>Downloading https://services.gradle.org/distributions/gradle-6.1.1-bin.zip
>.........10%.........20%.........30%..........40%.........50%
>.........60%..........70%.........80%.........90%.........100%
>
>Welcome to Gradle 6.1.1!
>
>Here are the highlights of this release:
>
> - Reusable dependency cache
> - Configurable compilation order between Groovy/Kotlin/Java/Scala
> - New sample projects in Gradle's documentation
>
>For more details see https://docs.gradle.org/6.1.1/release-notes.html
>
>Starting a Gradle Daemon (subsequent builds will be faster)
>
> Task :compileTestJava FAILED
>
>Code\SNR-Project\Anature\src\test\java\applicationTests\AppTest.java:16: error: >cannot find symbol
> asserNotNull(classUnderTest.getGreeting(), "app should have a greeting");
> ^
> symbol: method asserNotNull(String,String)
> location: class AppTest
>1 error
>
>FAILURE: Build failed with an exception.
>
>* What went wrong:
>Execution failed for task ':compileTestJava'.
> Compilation failed; see the compiler error output for details.
>
>* Try:
>Run with --stacktrace option to get the stack trace. Run with --info or --debug >option to get more log output. Run with --scan to get full insights.
>
>* Get more help at https://help.gradle.org
>
>BUILD FAILED in 31s
>6 actionable tasks: 6 executed
Here is the error I am getting in when I run the pipeline. This is a run in a Microsoft hosted VM.
>##[section]Starting: Gradle
>==============================================================================
>Task : Gradle
>Description : Build using a Gradle wrapper script
>Version : 2.163.0
>Author : Microsoft Corporation
>Help : >https://learn.microsoft.com/azure/devops/pipelines/tasks/build/gradle
>==============================================================================
>SYSTEMVSSCONNECTION exists true
>[command]/home/vsts/work/1/s/Anature/gradlew --refresh-dependencies build
>Downloading https://services.gradle.org/distributions/gradle-6.1.1-bin.zip
>.........10%.........20%.........30%..........40%.........50%
>.........60%..........70%.........80%.........90%.........100%
>
>Welcome to Gradle 6.1.1!
>
>Here are the highlights of this release:
> - Reusable dependency cache
> - Configurable compilation order between Groovy/Kotlin/Java/Scala
> - New sample projects in Gradle's documentation
>
> For more details see https://docs.gradle.org/6.1.1/release-notes.html
>
> Starting a Gradle Daemon (subsequent builds will be faster)
>
> > Task :compileJava
> /home/vsts/work/1/s/Anature/src/main/java/application/Player.java:5: error: >package javafx.scene.image does not exist
> import javafx.scene.image.Image;
> ^
> /home/vsts/work/1/s/Anature/src/main/java/application/Player.java:12: error: >cannot find symbol
> private Image sprite;
> ^
> symbol: class Image
> location: class Player
> 2 errors
>
> > Task :compileJava FAILED
>
> FAILURE: Build failed with an exception.
>
> * What went wrong:
> Execution failed for task ':compileJava'.
> > Compilation failed; see the compiler error output for details.
>
> * Try:
> Run with --stacktrace option to get the stack trace. Run with --info or -->debug option to get more log output. Run with --scan to get full insights.
>
> * Get more help at https://help.gradle.org
>
> BUILD FAILED in 14s
> 1 actionable task: 1 executed
> Error: The process '/home/vsts/work/1/s/Anature/gradlew' failed with exit >code 1
> at ExecState._setResult (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94->4c97-85af-839254cc6da4/2.163.0/node_modules/azure-pipelines-task->lib/toolrunner.js:816:25)
> at ExecState.CheckComplete (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94->4c97-85af-839254cc6da4/2.163.0/node_modules/azure-pipelines-task->lib/toolrunner.js:799:18)
> at ChildProcess.<anonymous> (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94->4c97-85af-839254cc6da4/2.163.0/node_modules/azure-pipelines-task->lib/toolrunner.js:721:19)
> at emitTwo (events.js:106:13)
> at ChildProcess.emit (events.js:191:7)
> at maybeClose (internal/child_process.js:920:16)
> at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)
> No test result files matching /home/vsts/work/1/s/**/TEST-*.xml were found, >so publishing JUnit test results is being skipped.
> ##[error]Error: The process '/home/vsts/work/1/s/Anature/gradlew' failed with >exit code 1
> ##[section]Finishing: Gradle
So the issue is that in the Pipeline it's throwing an error saying that a JavaFX import does not exist. When in theory
./gradle build
should be installing the required libraries on the Microsoft VM to run the code.
Just in case anyone is interested here is my azure-pipelines.yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Gradle@2
inputs:
gradleWrapperFile: 'Anature/gradlew'
workingDirectory: 'Anature'
options: '--refresh-dependencies'
tasks: 'build'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
sonarQubeRunAnalysis: false
Here you can see I am trying to force install all the dependencies but still am getting a
package javafx.scene.image does not exist
Here are some reference links:
For Azure Gradle task. https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/gradle?view=azure-devops
Azure VM Specs: https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu1804-README.md
Gradle dependency information: https://docs.gradle.org/current/userguide/declaring_dependencies.html
Update:
I had to first figure out what an azure pipeline VM had stock on it and why JavaFX wasn't working.
Here is a link to the download Java 1.8 version that comes stock on the Azure VM.
http://repos.azul.com/azure-only/zulu/packages/zulu-8/8u222/
Once you download the Zulu package for java you will see that JavaFX was not apart of the Java download like it is for the Java JDK.