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.

html 复制代码
$ chmod 777 gradlew
$ ./gradlew build -x test
Starting a Gradle Daemon, 4 busy and 2 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
Gradle could not start your build.
> Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeServices.createResourceSnapshotterCacheService().
   > Timeout waiting to lock file hash cache (/cache/itwork/gradle/repository/caches/6.8/fileHashes). It is currently in use by another Gradle instance.
     Owner PID: 97
     Our PID: 97
     Owner Operation: 
     Our operation: 
     Lock file: /cache/itwork/gradle/repository/caches/6.8/fileHashes/fileHashes.lock

* Try:
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.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 47s
ERROR: Job failed: command terminated with exit code 1

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

修改后的ci文件如下:

html 复制代码
stages:
  - package
  - docker-build

package:
  stage: package
  script:
    - export GRADLE_USER_HOME=${GRADLE_USER_HOME}/${GROUP_NAME}/${CI_PROJECT_NAME}/.gradle
    - export PATH=GRADLE_USER_HOME/bin:$PATH
    - echo $GRADLE_USER_HOME
    - chmod 777 gradlew
    - ./gradlew build -x test
    - cp build/libs/app.jar ${CACHE_PIPELINE}/app.jar
  only:
    - master
    - tags
    - /^feature-.*$/
    - /^hotfix-.*$/
    - /^bugfix-.*$/
docker-build:
  stage: docker-build
  script:
    - update_dockerfile
    - docker_build .
    - update_charts_base v3 server
    - chart_build
  only:
    - master
    - tags
    - /^release-.*$/
    - /^hotfix-.*$/
    - /^bugfix-.*$/
    - /^feature-.*$/

.auto_devops: &auto_devops |
  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"`
  if [ "$http_status_code" != "200" ]; then
    cat .auto_devops.sh
    exit 1
  fi
  source .auto_devops.sh
before_script:
  - *auto_devops

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

  • export GRADLE_USER_HOME={GRADLE_USER_HOME}/{GROUP_NAME}/${CI_PROJECT_NAME}/.gradle

  • export PATH=GRADLE_USER_HOME/bin:$PATH

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

相关推荐
nuczzz10 小时前
GPU虚拟化
docker·kubernetes·k8s·gpu·nvidia
上海运维Q先生15 小时前
Cilium动手实验室: 精通之旅---13.Cilium LoadBalancer IPAM and L2 Service Announcement
云原生·k8s·cilium
上海运维Q先生2 天前
Cilium动手实验室: 精通之旅---11.Advanced BGP Features - Lab
云原生·k8s·cilium
星释2 天前
如何自动部署GitLab项目
gitlab
keson要进步2 天前
CICD实战(二)-----gitlab的安装与配置
linux·运维·gitlab
Lw老王要学习2 天前
Linux容器篇、第二章_01Ubuntu22 环境下 KubeSphere 容器平台高可用搭建全流程
linux·运维·服务器·k8s·kubesphere·容器化
猫头虎3 天前
[特殊字符]解决 “IDEA 登录失败。不支持早于 14.0 的 GitLab 版本” 问题的几种方法
java·ide·网络协议·http·https·gitlab·intellij-idea
风早君3 天前
jenkins集成gitlab发布到远程服务器
服务器·gitlab·jenkins
剑哥在胡说4 天前
Kubernetes (k8s)版本发布情况
k8s
上海运维Q先生4 天前
Cilium动手实验室: 精通之旅---4.Cilium Gateway API - Lab
云原生·k8s·cilium