0

I have a gradle project which I want to build on a self hosted agent in Azure DevOps.

Here is my pipeline with the gradle task:

trigger:
 - azure-pipelines

pool:
 name: Default

steps:

 - task: Gradle@2
   inputs:
   workingDirectory: ''
   gradleWrapperFile: 'gradlew'
   gradleOptions: '-Xmx3072m'
   javaHomeOption: 'JDKVERSION'
   jdkVersionOption: 1.8
   jdkArchitectureOption: x64
   jdkUserInputPath: '/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java'
   publishJUnitResults: false
   testResultsFiles: '**/TEST-*.xml'
   tasks: 'build'

But if I run the pipeline I got the following problem:

Error: The process '/azp/agent/_work/1/s/gradlew' failed with exit code 126
at ExecState._setResult (/azp/agent/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.176.0/node_modules/azure-pipelines-task-lib/toolrunner.js:816:25)
at ExecState.CheckComplete (/azp/agent/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.176.0/node_modules/azure-pipelines-task-lib/toolrunner.js:799:18)
at ChildProcess.<anonymous> (/azp/agent/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.176.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 Socket.<anonymous> (internal/child_process.js:351:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:509:12)

SYSTEMVSSCONNECTION exists true
   /azp/agent/_work/1/s/gradlew build
   /usr/bin/env: 'sh': Not a directory
   ##[error]Error: The process '/azp/agent/_work/1/s/gradlew' failed with exit code 126

I have tried manually to run the gradlew wrapper on the agent, it worked without a problem.

Dokksen
  • 372
  • 1
  • 4
  • 17
  • 1
    Are you building an android app or a java app? What operating system are you using? Do you have the same issue if you use a Microsoft-hosted agent? According to your error message:/usr/bin/env: 'sh': Not a directory. This may be related to line break types. Please refer to [this ticket](https://stackoverflow.com/questions/22301956/error-with-gradlew-usr-bin-env-bash-no-such-file-or-directory) for more details. – Walter Oct 22 '20 at 08:20
  • @WalterQian-MSFT I am building a java app. I am using windows, but my agent is linux. I have the same problem if a use a microsoft agent. I also saw this ticket, but the solution didnt work for me, I converted it to unix style using notepad++. – Dokksen Oct 22 '20 at 08:29
  • 1
    You mentioned that you ran the gradlew wrapper command. What is the result of running gradlew build command? This is the command that should be used and the command used by the gradle task in pipelines. I followed this [sample](https://spring.io/guides/gs/gradle/) and it worked on my side. You can refer to it. – Walter Oct 23 '20 at 09:49
  • 1
    @WalterQian-MSFT I solved the problem. I set a new repository with the pipeline, now everything works. I think, it was a problem with my old repo. But I thank you for your efforts. – Dokksen Oct 23 '20 at 13:46
  • 1
    Glad to hear that you have solved the problem. Would you please share your answer and mark it? This will make it easier for people who have the same question to find answers. – Kevin Lu-MSFT Oct 27 '20 at 09:01

1 Answers1

0

I could solve the problem. I just set a new repository with the pipeline, now everything works. I think, it was a problem with my old repo.

Dokksen
  • 372
  • 1
  • 4
  • 17