• k8s gitlab cicd 之gradle 篇章(二)并发打包问题


    前文:https://caicongyang.blog.csdn.net/article/details/132049822?spm=1001.2014.3001.5502

    运行几天后发现以下问题: 

    Starting a Gradle Daemon, 4 busy and 2 stopped Daemons could not be reused, use --status for details

    FAILURE: Build failed with an exception.

    1. $ chmod 777 gradlew
    2. $ ./gradlew build -x test
    3. Starting a Gradle Daemon, 4 busy and 2 stopped Daemons could not be reused, use --status for details
    4. FAILURE: Build failed with an exception.
    5. * What went wrong:
    6. Gradle could not start your build.
    7. > Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeServices.createResourceSnapshotterCacheService().
    8. > Timeout waiting to lock file hash cache (/cache/itwork/gradle/repository/caches/6.8/fileHashes). It is currently in use by another Gradle instance.
    9. Owner PID: 97
    10. Our PID: 97
    11. Owner Operation:
    12. Our operation:
    13. Lock file: /cache/itwork/gradle/repository/caches/6.8/fileHashes/fileHashes.lock
    14. * Try:
    15. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    16. * Get more help at https://help.gradle.org
    17. BUILD FAILED in 1m 47s
    18. ERROR: Job failed: command terminated with exit code 1

    大概意思是就是无法并发打包;

    修改后的ci文件如下:

    1. stages:
    2. - package
    3. - docker-build
    4. package:
    5. stage: package
    6. script:
    7. - export GRADLE_USER_HOME=${GRADLE_USER_HOME}/${GROUP_NAME}/${CI_PROJECT_NAME}/.gradle
    8. - export PATH=GRADLE_USER_HOME/bin:$PATH
    9. - echo $GRADLE_USER_HOME
    10. - chmod 777 gradlew
    11. - ./gradlew build -x test
    12. - cp build/libs/app.jar ${CACHE_PIPELINE}/app.jar
    13. only:
    14. - master
    15. - tags
    16. - /^feature-.*$/
    17. - /^hotfix-.*$/
    18. - /^bugfix-.*$/
    19. docker-build:
    20. stage: docker-build
    21. script:
    22. - update_dockerfile
    23. - docker_build .
    24. - update_charts_base v3 server
    25. - chart_build
    26. only:
    27. - master
    28. - tags
    29. - /^release-.*$/
    30. - /^hotfix-.*$/
    31. - /^bugfix-.*$/
    32. - /^feature-.*$/
    33. .auto_devops: &auto_devops |
    34. http_status_code=`curl -o .auto_devops.sh -s -m 10 --connect-timeout 10 -w %{http_code} "${CHOERODON_URL}/devops-action/ci?gitlabProjectId=${CI_PROJECT_ID}&pipelineId=${CI_PIPELINE_ID}&token=${Token}&type=base&version=v1"`
    35. if [ "$http_status_code" != "200" ]; then
    36. cat .auto_devops.sh
    37. exit 1
    38. fi
    39. source .auto_devops.sh
    40. before_script:
    41. - *auto_devops

    核心修改点: 打包阶段每个项目设置不同的打包目录

    - export GRADLE_USER_HOME=${GRADLE_USER_HOME}/${GROUP_NAME}/${CI_PROJECT_NAME}/.gradle
    - export PATH=GRADLE_USER_HOME/bin:$PATH

    不知道各位大佬有没有更好的方法呢

  • 相关阅读:
    Kubernetes客户端认证(一)—— 基于CA证书的双向认证方式
    C++——二叉搜索树
    如何让游戏中的随机因素重新赢得玩家信任
    【Python学习笔记】在Python中如何实现单例模式
    discuzQ安装
    【学习笔记】云原生初步
    numpy.isclose
    position left设置居中,除了auto以外,还有什么方式
    PowerShell禁止运行脚本
    通过人才测评系统,对程序员岗位进行招聘测评
  • 原文地址:https://blog.csdn.net/caicongyang/article/details/133420905