microsoft / azure-pipelines-tasks

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

The process '/Users/runner/work/1/s/gradlew' failed with exit code 1 #19892

Open TteamMBK opened 1 month ago

TteamMBK commented 1 month ago

Task name

Azure Devops Pipeline Failed

Breaking task version

No response

Last working task version

No response

Regression Description

While running the pipeline in azure devops for Android application, there was an issue due to which the pipeline failed - "The process '/Users/runner/work/1/s/gradlew' failed with exit code 1" Here is the iscreenshot image

What can be done to mitigate the above issue as sometimes when we are running the pipeline, pipeline is successful but sometimes it is getting the error as mentioned above. Recently it has started failing a lot and success rate is a bit low which is causing problem as it is much more time consuming.

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 11

Relevant log output

##[debug]taskRunner fail
    at ExecState._setResult (/Users/runner/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.231.2/node_modules/azure-pipelines-task-lib/toolrunner.js:943:25)
    at ExecState.CheckComplete (/Users/runner/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.231.2/node_modules/azure-pipelines-task-lib/toolrunner.js:926:18)
    at ChildProcess.<anonymous> (/Users/runner/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.231.2/node_modules/azure-pipelines-task-lib/toolrunner.js:839:19)
    at ChildProcess.emit (node:events:518:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
##[debug]Processing code analysis results
##[debug]System.DefaultWorkingDirectory=/Users/runner/work/1/s
##[debug]build.artifactStagingDirectory=/Users/runner/work/1/a
##[debug]build.buildNumber=3.4.0
##[debug][CA] Attempting to find report files from 4 code analysis tool(s)
##[debug]checkstyleAnalysisEnabled=false
##[debug][CA] Checkstyle analysis is not enabled.
##[debug]findbugsAnalysisEnabled=false
##[debug][CA] FindBugs analysis is not enabled.
##[debug]pmdAnalysisEnabled=false
##[debug][CA] PMD analysis is not enabled.
##[debug]spotBugsAnalysisEnabled=false
##[debug][CA] SpotBugs analysis is not enabled.
##[debug][CA] Skipping artifact upload: No analysis results
##[debug]task result: Failed
##[error]Error: The process '/Users/runner/work/1/s/gradlew' failed with exit code 1
##[debug]Processed: ##vso[task.issue type=error;]Error: The process '/Users/runner/work/1/s/gradlew' failed with exit code 1
##[debug]Processed: ##vso[task.complete result=Failed;]Error: The process '/Users/runner/work/1/s/gradlew' failed with exit code 1
Finishing: Gradle

Full task logs with system.debug enabled

UNSUCCESSFUL RUN
 [REPLACE THIS WITH YOUR INFORMATION] 
SUCCESSFUL RUN
 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

# Android
# Build your Android project with Gradle.
# Add steps that test, sign, and distribute the APK, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/android

name: '$(prime).$(major).$(minor)'

pool:
  vmImage: 'macos-latest'

steps:
- task: Bash@3
  inputs:
    targetType: 'inline'
    script: |
      #!/usr/bin/env bash
      MANIFEST_PATH=app/src/main/AndroidManifest.xml
      VERSION_NAME=$(prime).$(major).$(minor)
      BUILD_NUMBER=$(Build.BuildId)
      TEMP_MANIFEST_PATH=${MANIFEST_PATH}.txt
      echo "Version Code=$BUILD_NUMBER"
      echo "Version Name=$VERSION_NAME"
      cat ${MANIFEST_PATH} | sed "s/android:versionCode=\".*\"/android:versionCode=\"${BUILD_NUMBER}\"/" > ${TEMP_MANIFEST_PATH}
      cat ${TEMP_MANIFEST_PATH} | sed "s/android:versionName=\".*\"/android:versionName=\"${VERSION_NAME}\"/" > ${MANIFEST_PATH}
      rm -f ${TEMP_MANIFEST_PATH}

- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: false
    testResultsFiles: '**/TEST-*.xml'
    tasks: assembleINTRelease

- task: AndroidSigning@3
  inputs:
    apkFiles: '**/*.apk'
    apksignerKeystoreFile: 'android_keystore'
    apksignerKeystorePassword: '$(keystorePassword)'
    apksignerKeystoreAlias: '$(keystoreAlias)'
    apksignerKeyPassword: '$(keystoreAliasPassword)'
    apksignerArguments: '--v1-signing-enabled true --v2-signing-enabled true --verbose'
    zipalign: false

- task: CopyFiles@2
  inputs:
    contents: '**/*.apk'
    targetFolder: '$(build.artifactStagingDirectory)'

- task: PublishBuildArtifacts@1

- task: AppCenterDistribute@3
  inputs:
    serverEndpoint: 'Daimler_Android_AppCenter'
    appSlug: 'Daimler-Care4Me-1/Care4Me-Int-1'
    appFile: '$(build.artifactStagingDirectory)/**/*.apk'
    symbolsOption: 'Android'
    releaseNotesOption: 'input'
    releaseNotesInput: 'Automated Release'
    destinationType: 'groups'
DmitriiBobreshev commented 1 month ago

Hi @TteamMBK, the error usually indicates that the called program returned exit code 1. In your case, gradlew returned exit code 1 and probably there is some error during the execution. Could you please share a full log with diagnostic logs enabled?

TteamMBK commented 1 month ago

error logs.txt Here is the txt file of logs

DmitriiBobreshev commented 1 month ago

Based on the logs I see that the task :eventoffers:kaptReleaseKotlin was failed with exception

2024-05-21T10:24:54.6902360Z e: java.lang.IllegalStateException: failed to analyze: com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: %fileName% (/io/realm/MutableRealmInteger.class)
2024-05-21T10:24:54.6927810Z   unable to access file: java.nio.file.ClosedFileSystemException
2024-05-21T10:24:54.7167060Z   Please remove or make sure it appears in the correct subdirectory of the classpath. 

I also see that in the pipeline jdk version is 1.11 but in the yml you set 1.8. Is your project should be built via 1.11 and gradle 6.5? Are you able to build it locally with same setup?

TteamMBK commented 1 month ago

Hi @DmitriiBobreshev

I tried your suggestion and changed jdk version in YML file from 1.8 to 1.11, then pushed code and run pipeline. but still (Android prod) pipeline got failed.

Yes, we are able to build our project locally.

DmitriiBobreshev commented 1 month ago

@TteamMBK, Thanks for the answer, from what we see, the task wasn't changed but the images chagned recently, specifically version of kotlin was changed from 1.9.23 to 1.9.24 on almost all images. Could you please try to test it with new version of Kotlin and create an issue in runner-images repository?

TteamMBK commented 1 month ago

Could you please elaborate a bit-

  1. do you want me to upgrade kotlin version of the code ?
  2. How to create issue in runner-images repository
DmitriiBobreshev commented 1 month ago

@TteamMBK,

  1. It would be great if you could try to build the project with the same setup as on ms-hosted agent where the Kotlin version is 1.9.24-release-822.
  2. The runner images repository is located on GHl, this repo is for ms-hosted images. As I suspect that something may be incorrect with a software and not with the task, this might help to find a root cause.
TteamMBK commented 1 month ago

@DmitriiBobreshev

For #1. We changed the version of pipeline same as of our Android studio but still getting the same error

image