• 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

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

  • 相关阅读:
    Flink(六)【DataFrame 转换算子(下)】
    Python——基于YOLOV8的车牌识别(源码+教程)
    nvm:npm ERR! Unexpected token ‘.‘
    安卓性能优化,UI优化漫谈
    Jmeter组件
    再读HorNet论文
    护眼灯国A与国AA级差别是什么?推荐双十一值得入手的国AA的护眼灯
    剑指 Offer 10- I. 斐波那契数列
    JavaWeb管理系统与技术博客
    SQL查询语句中DISTINCT去重的方法,DISTINCT必须放在第一位
  • 原文地址:https://blog.csdn.net/caicongyang/article/details/133420905