2

I have a Jenkins instance running that should build an Android project. When I start the task, I receive the following exception:

Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory()

Failed to create parent directory '/home/espresso/jenkins_workspace/workspace/myproject/.gradle' when creating directory '/home/espresso/jenkins_workspace/workspace/myproject/.gradle/4.1/fileHashes'

Jenkins runs as root, ls -la for myproject folder is:

drwxr-xr-x 11 root root 4096 Nov 16 15:07 myproject

The environment variable GRADLE_USER_HOME is set to /home/espresso/.gradle, ls -la for that folder gives:

drwxrwxrwx   6 root     root       4096 Nov 16 11:30 .gradle

Why can't Jenkins create that folder? The whole directory structure under jenkins_workspace was created by Jenkins, so the permissions should be okay?

fweigl
  • 384
  • 5
  • 14
  • `jenkins runs as root` what makes you sure about this? – derHugo Nov 16 '17 at 17:18
  • @derHugo a. running 'whoami' in the build task prints 'root' b. the task checks out the project from Github, after checking out, all the files are owned by 'root' – fweigl Nov 16 '17 at 17:54
  • Does it only happen with Jenkins? If you log in as root and run the script, does it work? – Katu Nov 17 '17 at 08:40
  • @Katu Yes, when I login as root, I can create any folders, and running the same gradle command as the script would do runs fine. – fweigl Nov 17 '17 at 09:08
  • 1
    @Ascorbin Have you checked the value of GRADLE_USER_HOME within the jenkins script? Do you clean before running it? How do run the script as root? https://stackoverflow.com/questions/30840526/gradle-could-not-create-service-of-type-initscripthandler-using-buildscopeservic – Katu Nov 17 '17 at 11:25
  • @Katu Your comment brought me on the right track. thanks very much. – fweigl Nov 17 '17 at 12:26

1 Answers1

2

Everything runs fine after checking the box

Force GRADLE_USER_HOME to use workspace

on the Jenkins Gradle Plugin.

Why this makes it work, I don't know. The environment variable $GRADLE_USER_HOME for the job was set to /home/espresso/.gradle and the job, as root, had all permissions for that folder. Also, I don't understand why missing permissions in one gradle folder would lead to the job not being able to create files in another gradle folder.

fweigl
  • 384
  • 5
  • 14