microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.47k stars 2.6k forks source link

[Question]: My self-hosted agent cannot find gradlew #19788

Open rotekii opened 5 months ago

rotekii commented 5 months ago

Task name

gradle

Task version

No response

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

windows server

Question

I'm still a beginner into this and I'm trying to run my first simple CI to an android app. 
trigger:
- develop

pool:
  name: default

steps:
- checkout: none  # Disable automatic checkout
- task: Gradle@3
  inputs:
    gradleWrapperFile: 'gradlew'
    tasks: 'build'
    publishJUnitResults: true
    testResultsFiles: '**/TEST-*.xml'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    gradleOptions: '-Xmx3072m'
    sonarQubeRunAnalysis: false
    spotBugsAnalysis: false

and this is the result
##[error]Error: Not found wrapperScript: C:\Users\Administrateur\agent\_work\1\s\gradlew

if you may ask, yes gradle is on the root directory. and when i'm looking into C:\Users\Administrateur\agent\_work\1\s\gradlew it is indeed empty
rotekii commented 5 months ago

fixed it steps:

but now i'm dealing <with a new problem 2024-04-17T13:59:42.8324728Z ##[section]Starting: Gradle 2024-04-17T13:59:42.8358288Z ============================================================================== 2024-04-17T13:59:42.8358382Z Task : Gradle 2024-04-17T13:59:42.8358427Z Description : Build using a Gradle wrapper script 2024-04-17T13:59:42.8358484Z Version : 3.238.1 2024-04-17T13:59:42.8358524Z Author : Microsoft Corporation 2024-04-17T13:59:42.8358575Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/gradle 2024-04-17T13:59:42.8358651Z ============================================================================== 2024-04-17T13:59:43.0785734Z [command]/home/nada/myagent/_work/3/s/gradlew build 2024-04-17T13:59:43.5567557Z Starting a Gradle Daemon, 1 incompatible and 4 stopped Daemons could not be reused, use --status for details 2024-04-17T13:59:44.4549028Z Configuration on demand is an incubating feature. 2024-04-17T13:59:46.9549230Z Type-safe project accessors is an incubating feature. 2024-04-17T13:59:49.2546949Z 2024-04-17T13:59:49.2558152Z > Configure project : 2024-04-17T13:59:49.2561537Z Project accessors enabled, but root project name not explicitly set for 'plugins'. Checking out the project in different folders will impact the generated code and implicitly the buildscript classpath, breaking caching. 2024-04-17T13:59:50.5547751Z 2024-04-17T13:59:50.5550391Z > Task :plugins:generateExternalPluginSpecBuilders FROM-CACHE 2024-04-17T13:59:50.5551177Z > Task :plugins:extractPrecompiledScriptPluginPlugins FROM-CACHE 2024-04-17T13:59:50.5561877Z > Task :plugins:compilePluginsBlocks FROM-CACHE 2024-04-17T13:59:52.0547786Z > Task :plugins:generatePrecompiledScriptPluginAccessors 2024-04-17T13:59:52.0548248Z > Task :plugins:generateScriptPluginAdapters FROM-CACHE 2024-04-17T13:59:52.3550650Z > Task :plugins:compileKotlin FROM-CACHE 2024-04-17T13:59:52.3551211Z > Task :plugins:compileJava NO-SOURCE 2024-04-17T13:59:52.3551556Z > Task :plugins:pluginDescriptors 2024-04-17T13:59:52.4547194Z > Task :plugins:processResources 2024-04-17T13:59:52.4549078Z > Task :plugins:classes 2024-04-17T13:59:52.4549732Z > Task :plugins:inspectClassesForKotlinIC 2024-04-17T13:59:52.6549920Z > Task :plugins:jar 2024-04-17T13:59:53.3546905Z 2024-04-17T13:59:53.3547495Z > Configure project :app 2024-04-17T13:59:53.3548151Z WARNING:The option setting 'android.experimental.lint.version=8.0.0-alpha10' is experimental. 2024-04-17T13:59:54.1547637Z WARNING:BuildType(nightly): resValue 'string/app_name' value is being replaced. 2024-04-17T13:59:57.0556690Z 2024-04-17T13:59:57.0557513Z FAILURE: Build failed with an exception. 2024-04-17T13:59:57.0557759Z 2024-04-17T13:59:57.0558035Z What went wrong: 2024-04-17T13:59:57.0558642Z A problem occurred configuring project ':libraries:rustsdk'. 2024-04-17T13:59:57.0559358Z > Could not open proj generic class cache for build file '/home/nada/myagent/_work/3/s/libraries/rustsdk/build.gradle' (/home/nada/.gradle/caches/7.5.1/scripts/5s1ak5rssh3e33ty70252onac). 2024-04-17T13:59:57.0560136Z > BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 63 2024-04-17T13:59:57.0560330Z 2024-04-17T13:59:57.0560469Z Try: 2024-04-17T13:59:57.0560763Z > Run with --stacktrace option to get the stack trace. 2024-04-17T13:59:57.0561107Z > Run with --info or --debug option to get more log output. 2024-04-17T13:59:57.0561424Z > Run with --scan to get full insights. 2024-04-17T13:59:57.0592870Z 2024-04-17T13:59:57.0593268Z * Get more help at https://help.gradle.org 2024-04-17T13:59:57.4095708Z 2024-04-17T13:59:57.4096196Z BUILD FAILED in 13s 2024-04-17T13:59:57.4096517Z 10 actionable tasks: 5 executed, 5 from cache 2024-04-17T13:59:57.4096655Z 2024-04-17T13:59:57.4161187Z Error: The process '/home/nada/myagent/_work/3/s/gradlew' failed with exit code 1 2024-04-17T13:59:57.4163382Z at ExecState._setResult (/home/nada/myagent/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/3.238.1/node_modules/azure-pipelines-task-lib/toolrunner.js:943:25) 2024-04-17T13:59:57.4166226Z at ExecState.CheckComplete (/home/nada/myagent/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/3.238.1/node_modules/azure-pipelines-task-lib/toolrunner.js:926:18) 2024-04-17T13:59:57.4167263Z at ChildProcess. (/home/nada/myagent/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/3.238.1/node_modules/azure-pipelines-task-lib/toolrunner.js:839:19) 2024-04-17T13:59:57.4167794Z at ChildProcess.emit (node:events:518:28) 2024-04-17T13:59:57.4168148Z at maybeClose (node:internal/child_process:1105:16) 2024-04-17T13:59:57.4168544Z at ChildProcess._handle.onexit (node:internal/child_process:305:5) 2024-04-17T13:59:57.6058497Z No test result files matching /home/nada/myagent/_work/3/s/*/TEST-.xml were found, so publishing JUnit test results is being skipped. 2024-04-17T13:59:57.6084689Z ##[error]Code analysis failed. Gradle exit code: -1. Error: Error: The process '/home/nada/myagent/_work/3/s/gradlew' failed with exit code 1 2024-04-17T13:59:57.6111143Z ##[section]Finishing: Gradle

aleksandrlevochkin commented 4 months ago

Hi @rotekii thank you for reporting. This new error seems related to a different issue. While looking for this error message on Gradle forums I found that it is often caused by incompatibility between the versions of Gradle and JDK. Can it be the case for you?

rotekii commented 4 months ago

Hi @rotekii thank you for reporting. This new error seems related to a different issue. While looking for this error message on Gradle forums I found that it is often caused by incompatibility between the versions of Gradle and JDK. Can it be the case for you?

Hi @aleksandrlevochkin , yes i have already figured out how to fix it but now I'm confronting a new problem and I'm trying to integrate the pipeline with SonarQube.

and the error that i'm getting is this https://dev.azure.com/nadamajd/a57302b0-a613-48ab-ab09-69c1867f7f38/_apis/build/builds/742/logs/10

And because of that i can't seem to have a succeded job, neither results on SonarQube.

Here is my new code


  inputs:
    SonarQube: 'name_of_service_connection'
    scannerMode: 'Other'
    extraProperties: |
      # Additional properties that will be passed to the scanner,
      # Put one key=value per line, example:
      # sonar.exclusions=**/*.bin
      sonar.projectKey=my_project_key
      sonar.projectName=my_project_name

- script: |
    java -version
    wget https://builds.openlogic.com/downloadJDK/openlogic-openjdk/17.0.10+7/openlogic-openjdk-17.0.10+7-linux-x64.tar.gz -O JAVA_HOME_17_X64.tar.gz
    tree
  displayName: Download JDK17

- task: JavaToolInstaller@0
  inputs:
    versionSpec: '17'
    jdkArchitectureOption: 'x64'
    jdkSourceOption: 'LocalDirectory'
    jdkFile: 'JAVA_HOME_17_X64.tar.gz'
    jdkDestinationDirectory: '$(Agent.ToolsDirectory)/JAVA_HOME_17/X64'
    cleanDestinationDirectory: true
    createExtractDirectory: false

- script: |
    java -version
    echo Environment Variable JAVA_HOME_17_X64 is $(JAVA_HOME_17_X64)
    tree $(Agent.ToolsDirectory)
  displayName: Check JDK version

- task: Gradle@3
  inputs:
    gradleWrapperFile: '$(Build.Repository.LocalPath)/gradlew'
    workingDirectory: '$(Build.Repository.LocalPath)'
    tasks: 'build'
    publishJUnitResults: true
    testResultsFiles: '**/TEST-*.xml'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.17' # Use pre-installed JAVA17
    gradleOptions: '-Xmx3072m'
    sonarQubeRunAnalysis: true
    sqGradlePluginVersionChoice: 'specify'
    sonarQubeGradlePluginVersion: '2.6.1'
    spotBugsAnalysis: false

- task: SonarQubePublish@5
  inputs:
    pollingTimeoutSec: '300'```
aleksandrlevochkin commented 4 months ago

@rotekii Looks like the error message is: Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. It seems related to your Gradle configuration rather than the pipeline task.

Also, is your repo meant to be public? If it contains any sensitive information, please remove the link.