ARTIFACTORY: Resolving Gradle builds permission denied error in Azure devops pipeline
If you come across any permission denied error while running Gradle builds in Azure devops pipeline such as below:-
[Error] fork/exec ./gradlew: permission denied ##[error]Error: Command failed: /opt/hostedtoolcache/jf/2.52.9/x64/jf gradle artifactoryPublish -d -b /home/vsts/work/1/s/build.gradle --build-name="***jfrog.gradlerepo" --build-number="20240123.11"
The above error indicates that Gradle likely exists in the correct place, but it is not executable and the pipeline fails with permission denied error.
Solution:You need to update the execution permission for this file . If you are running locally you can run chmod in your terminal:-
#chmod +x gradlew
In azure devops pipeline, please try giving all permissions for that file by adding below command line task in your Azure pipelines.YML file
- task: CmdLine@2 inputs: script: 'chmod 777 gradlew'