jenkins shared library java azure sdk plugin import error in gradle project

124 Views Asked by At

I am new to this Jenkins and Gradle and I am trying to build a Gradle project which is using java azure SDK libraries and getting below error before allotting the build node which means it is throwing the error in the Jenkins server itself (once the git checkout is done)

I have already added the necessary plugins in the build.gradle and my IntelliJ IDE is showing the function and methods etc.,

        compile 'com.microsoft.azure:azure:1.41.4'
        compile 'com.azure:azure-core:1.17.0'
        compile 'com.azure:azure-identity:1.8.1'
        compile 'com.azure:azure-sdk-bom:1.2.11'
        compile 'com.azure:azure-core-http-netty:1.13.1'
        compile 'com.azure.resourcemanager:azure-resourcemanager-network:2.25.0'
        compile 'com.azure.resourcemanager:azure-resourcemanager:2.25.0'
        compile 'com.azure.resourcemanager:azure-resourcemanager-frontdoor:1.0.0-beta.2'
        compile 'com.microsoft.azure:azure-mgmt-containerservice:1.41.4'
        compile 'com.azure.resourcemanager:azure-resourcemanager-containerservice:2.25.0'
org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed:
/var/jenkins_home/jobs/BK-SSLCertCheck/builds/301/libs/1609fa01e7dd59643f39e4905bdbb221ec7fe4ce82a392e19a28a060015ae9c9/vars/job_AzureAKSCluster.groovy: 14: unable to resolve class com.microsoft.azure.management.containerservice.KubernetesClusters
 @ line 14, column 1.
   import com.microsoft.azure.management.containerservice.KubernetesClusters
   ^

/var/jenkins_home/jobs/BK-SSLCertCheck/builds/301/libs/1609fa01e7dd59643f39e4905bdbb221ec7fe4ce82a392e19a28a060015ae9c9/vars/job_AzureAKSCluster.groovy: 13: unable to resolve class com.microsoft.azure.management.containerservice.KubernetesCluster
 @ line 13, column 1.
   import com.microsoft.azure.management.containerservice.KubernetesCluster
   ^

I tried installing Azure SDK API Plugin Version118.v43f74dd9ca_dc but that didn't help

1

There are 1 best solutions below

2
Pravallika KV On

org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed:/var/jenkins_home/jobs/BK-SSLCertCheck/builds/301/libs/1609fa01e7dd59643f39e4905bdbb221ec7fe4ce82a392e19a28a060015ae9c9/vars/job_AzureAKSCluster.groovy: 14: unable to resolve class com.microsoft.azure.management.containerservice.KubernetesClusters @ line 14, column 1. import com.microsoft.azure.management.containerservice.KubernetesClusters

  • This error usually occurs if you don't have the required dependencies in your application or if the packages you have are not compatible with the Gradle version.

  • Make sure you have all the required dependencies and your Gradle version is compatible with those dependencies.

I have reproduced your requirement in my environment with all the required dependencies using Azure Java SDK.

  • you can refer to my github repository for the code.

As you can see in the manage cluster.java class, I have imports related AKS.

enter image description here

Gradle build configuration in Jenkins:

enter image description here

enter image description here

enter image description here

enter image description here

Result:

I could successfully Build the project without any issues as shown below:

enter image description here

enter image description here

enter image description here