Gradle build on GitLab CI: Could not create service of type ScriptPluginFactory











up vote
0
down vote

favorite












Using parallel Gradle jobs on GitLab CI:



Parallel Gradle jobs



I'm receiving following random Gradle exception:



FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeScopeServices.createResourceSnapshotterCacheService().


I use a docker executor of gitlab-runner without any GitLab CI caching. I use a Docker volume instead with Gradle cache pointing to that volume:



before_script:
- export GRADLE_USER_HOME=/pipelines/.gradle


There is no issue with access rights to the /pipelines directory (so it's not duplicity of this question).



Simple, but annoying workaround to this issue is just to re-trigger the failed job manually - then it passes without any problem. Another workaround could to re-trigger the job automatically via the retry directive.



So, my question is: What is causing the job failure and how to solve it (without job re-triggering)?










share|improve this question


























    up vote
    0
    down vote

    favorite












    Using parallel Gradle jobs on GitLab CI:



    Parallel Gradle jobs



    I'm receiving following random Gradle exception:



    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
    > Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeScopeServices.createResourceSnapshotterCacheService().


    I use a docker executor of gitlab-runner without any GitLab CI caching. I use a Docker volume instead with Gradle cache pointing to that volume:



    before_script:
    - export GRADLE_USER_HOME=/pipelines/.gradle


    There is no issue with access rights to the /pipelines directory (so it's not duplicity of this question).



    Simple, but annoying workaround to this issue is just to re-trigger the failed job manually - then it passes without any problem. Another workaround could to re-trigger the job automatically via the retry directive.



    So, my question is: What is causing the job failure and how to solve it (without job re-triggering)?










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Using parallel Gradle jobs on GitLab CI:



      Parallel Gradle jobs



      I'm receiving following random Gradle exception:



      FAILURE: Build failed with an exception.

      * What went wrong:
      Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
      > Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeScopeServices.createResourceSnapshotterCacheService().


      I use a docker executor of gitlab-runner without any GitLab CI caching. I use a Docker volume instead with Gradle cache pointing to that volume:



      before_script:
      - export GRADLE_USER_HOME=/pipelines/.gradle


      There is no issue with access rights to the /pipelines directory (so it's not duplicity of this question).



      Simple, but annoying workaround to this issue is just to re-trigger the failed job manually - then it passes without any problem. Another workaround could to re-trigger the job automatically via the retry directive.



      So, my question is: What is causing the job failure and how to solve it (without job re-triggering)?










      share|improve this question













      Using parallel Gradle jobs on GitLab CI:



      Parallel Gradle jobs



      I'm receiving following random Gradle exception:



      FAILURE: Build failed with an exception.

      * What went wrong:
      Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
      > Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeScopeServices.createResourceSnapshotterCacheService().


      I use a docker executor of gitlab-runner without any GitLab CI caching. I use a Docker volume instead with Gradle cache pointing to that volume:



      before_script:
      - export GRADLE_USER_HOME=/pipelines/.gradle


      There is no issue with access rights to the /pipelines directory (so it's not duplicity of this question).



      Simple, but annoying workaround to this issue is just to re-trigger the failed job manually - then it passes without any problem. Another workaround could to re-trigger the job automatically via the retry directive.



      So, my question is: What is causing the job failure and how to solve it (without job re-triggering)?







      docker gradle gitlab-ci gitlab-ci-runner






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 7 at 9:11









      Vít Kotačka

      420419




      420419
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          Root cause:



          After some debugging (switches --stacktrace and --info), it's obvious that the root cause is that multiple Docker containers are sharing one Gradle cache on the host machine.



          Caused by: org.gradle.cache.LockTimeoutException: Timeout waiting to lock file hash cache (/pipelines/.gradle/caches/4.10.2/fileHashes). It is currently in use by another Gradle instance.
          Owner PID: 158
          Our PID: 160
          Owner Operation:
          Our operation:
          Lock file: /pipelines/.gradle/caches/4.10.2/fileHashes/fileHashes.lock


          Solution:



          There is still unsolved Gradle bug/feature: Let multiple containers share downloaded dependencies. Therefore I (re)implemented proper Gradle caching per each involved GitLab CI job (so, no shared cache 😢):



          before_script:
          - export GRADLE_USER_HOME=`pwd`/.gradle

          rpmClient:
          stage: buildRpm
          script:
          - gradle clientRpm
          cache:
          paths:
          - .gradle/caches





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186389%2fgradle-build-on-gitlab-ci-could-not-create-service-of-type-scriptpluginfactory%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote













            Root cause:



            After some debugging (switches --stacktrace and --info), it's obvious that the root cause is that multiple Docker containers are sharing one Gradle cache on the host machine.



            Caused by: org.gradle.cache.LockTimeoutException: Timeout waiting to lock file hash cache (/pipelines/.gradle/caches/4.10.2/fileHashes). It is currently in use by another Gradle instance.
            Owner PID: 158
            Our PID: 160
            Owner Operation:
            Our operation:
            Lock file: /pipelines/.gradle/caches/4.10.2/fileHashes/fileHashes.lock


            Solution:



            There is still unsolved Gradle bug/feature: Let multiple containers share downloaded dependencies. Therefore I (re)implemented proper Gradle caching per each involved GitLab CI job (so, no shared cache 😢):



            before_script:
            - export GRADLE_USER_HOME=`pwd`/.gradle

            rpmClient:
            stage: buildRpm
            script:
            - gradle clientRpm
            cache:
            paths:
            - .gradle/caches





            share|improve this answer



























              up vote
              1
              down vote













              Root cause:



              After some debugging (switches --stacktrace and --info), it's obvious that the root cause is that multiple Docker containers are sharing one Gradle cache on the host machine.



              Caused by: org.gradle.cache.LockTimeoutException: Timeout waiting to lock file hash cache (/pipelines/.gradle/caches/4.10.2/fileHashes). It is currently in use by another Gradle instance.
              Owner PID: 158
              Our PID: 160
              Owner Operation:
              Our operation:
              Lock file: /pipelines/.gradle/caches/4.10.2/fileHashes/fileHashes.lock


              Solution:



              There is still unsolved Gradle bug/feature: Let multiple containers share downloaded dependencies. Therefore I (re)implemented proper Gradle caching per each involved GitLab CI job (so, no shared cache 😢):



              before_script:
              - export GRADLE_USER_HOME=`pwd`/.gradle

              rpmClient:
              stage: buildRpm
              script:
              - gradle clientRpm
              cache:
              paths:
              - .gradle/caches





              share|improve this answer

























                up vote
                1
                down vote










                up vote
                1
                down vote









                Root cause:



                After some debugging (switches --stacktrace and --info), it's obvious that the root cause is that multiple Docker containers are sharing one Gradle cache on the host machine.



                Caused by: org.gradle.cache.LockTimeoutException: Timeout waiting to lock file hash cache (/pipelines/.gradle/caches/4.10.2/fileHashes). It is currently in use by another Gradle instance.
                Owner PID: 158
                Our PID: 160
                Owner Operation:
                Our operation:
                Lock file: /pipelines/.gradle/caches/4.10.2/fileHashes/fileHashes.lock


                Solution:



                There is still unsolved Gradle bug/feature: Let multiple containers share downloaded dependencies. Therefore I (re)implemented proper Gradle caching per each involved GitLab CI job (so, no shared cache 😢):



                before_script:
                - export GRADLE_USER_HOME=`pwd`/.gradle

                rpmClient:
                stage: buildRpm
                script:
                - gradle clientRpm
                cache:
                paths:
                - .gradle/caches





                share|improve this answer














                Root cause:



                After some debugging (switches --stacktrace and --info), it's obvious that the root cause is that multiple Docker containers are sharing one Gradle cache on the host machine.



                Caused by: org.gradle.cache.LockTimeoutException: Timeout waiting to lock file hash cache (/pipelines/.gradle/caches/4.10.2/fileHashes). It is currently in use by another Gradle instance.
                Owner PID: 158
                Our PID: 160
                Owner Operation:
                Our operation:
                Lock file: /pipelines/.gradle/caches/4.10.2/fileHashes/fileHashes.lock


                Solution:



                There is still unsolved Gradle bug/feature: Let multiple containers share downloaded dependencies. Therefore I (re)implemented proper Gradle caching per each involved GitLab CI job (so, no shared cache 😢):



                before_script:
                - export GRADLE_USER_HOME=`pwd`/.gradle

                rpmClient:
                stage: buildRpm
                script:
                - gradle clientRpm
                cache:
                paths:
                - .gradle/caches






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 7 at 13:39

























                answered Nov 7 at 13:28









                Vít Kotačka

                420419




                420419






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186389%2fgradle-build-on-gitlab-ci-could-not-create-service-of-type-scriptpluginfactory%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Academy of Television Arts & Sciences

                    L'Équipe

                    1995 France bombings