• DevOps
  • git 克隆代码阶段缓慢--JENKINS-30600 警告, Git 未在指定容器内运行

kubesphere :v4.1.2 k8s:1.26.12 容器运行时:containerd 1.7

jekins-agent pod 使用的maven 容器git clone代码这一步骤很慢,但是在服务器本地上克隆很快,可能这个告警对git克隆速度有影响? 麻烦大佬指点一下如何解决警告,以及加快git clone 速度 :

以下是流水线打印日志:

The recommended git tool is: NONE

using credential gitlab

Warning: JENKINS-30600: special launcher org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1@420d9520; decorates RemoteLauncher[hudson.remoting.Channel@aff4583:JNLP4-connect connection from 10.233.90.75/10.233.90.75:41000] will be ignored (a typical symptom is the Git executable not being run inside a designated container)

Cloning the remote Git repository

Cloning repository http://xx.xx.xx.xx/hhh-www/qqq/aaa.git

 > git init /home/jenkins/agent/workspace/gjl-devn8mm7/atc-dev # timeout=10

Fetching upstream changes from http://xx.xx.xx.xx/hhh-www/qqq/aaa.git

 > git –version # timeout=10

 > git –version # ‘git version 2.30.2’

using GIT_ASKPASS to set credentials

 > git fetch –tags –force –progress – http://xx.xx.xx.xx/hhh-www/qqq/aaa.git +refs/heads/*:refs/remotes/origin/* # timeout=10

Avoid second fetch

Checking out Revision a5358f2218c5bfefd84200990d03119bb4a82625 (refs/remotes/origin/dev)

 > git config remote.origin.url http://xx.xx.xx.xx/hhh-www/qqq/aaa.git # timeout=10

 > git config –add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10

 > git rev-parse refs/remotes/origin/dev^{commit} # timeout=10

 > git config core.sparsecheckout # timeout=10

 > git checkout -f a5358f2218c5bfefd84200990d03119bb4a82625 # timeout=10

 > git branch -a -v –no-abbrev # timeout=10

 > git checkout -b dev a5358f2218c5bfefd84200990d03119bb4a82625 # timeout=10

Commit message: “Merge remote-tracking branch ‘origin/dev’ into dev”

 > git rev-list –no-walk a5358f2218c5bfefd84200990d03119bb4a82625 # timeout=10

下面是我的流水线代码:

pipeline {

agent {

node {

  label 'maven'

}

}

stages {

stage('clone code') {

  agent none

  steps {

    container('maven') {

      git(url: 'http://192.168.10.5/wxw/ruoyi-cloud.git', credentialsId: 'gitlab', branch: 'ruoyi', changelog: true, poll: false)

    }

    sh 'pwd && ls -al'

  }

}

}

补充一下:我将git 阶段的流水线代码改了,将 “agent none” 和 “container(‘maven’)” 去掉后,没有报这个warning 了

Warning: JENKINS-30600: special launcher org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1@420d9520; decorates RemoteLauncher[hudson.remoting.Channel@aff4583:JNLP4-connect connection from 10.233.90.75/10.233.90.75:41000] will be ignored (a typical symptom is the Git executable not being run inside a designated container)

但是,初始化git 这个动作还是很慢,会在 The recommended git tool is: NONE 这里加载1分钟左右,然后再进入

using credential gitlab,后面拉去代码的速度是正常的,

我没有什么思路,服务器物理硬件性能是很好的,瓶颈再哪里呢?

下面是完整的流水线代码

Started by user admin
[Pipeline] Start of Pipeline
[Pipeline] node
Still waiting to schedule task
maven-krr0p’ is offline
Agent maven-krr0p is provisioned from template maven
---
apiVersion: “v1”
kind: “Pod”
metadata:
annotations: {}
labels:
jenkins: “slave”
jenkins/label-digest: “f7e2f2535bb93611f7b95e2aaa3101be4b65c2fa”
jenkins/label: “maven”
name: “maven-krr0p”
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference:
matchExpressions:
- key: “node-role.kubernetes.io/worker”
operator: “In”
values:
- “ci”
weight: 100
containers:

  • command:
    • “cat”
      image: “dockerhub.kubekey.local/ks/kubesphere/builder-maven:v3.2.0-podman”
      imagePullPolicy: “IfNotPresent”
      name: “maven”
      resources:
      limits:
      cpu: “4000m”
      ephemeral-storage: “10Gi”
      memory: “8192Mi”
      requests:
      cpu: “100m”
      ephemeral-storage: “1Gi”
      memory: “100Mi”
      securityContext:
      privileged: true
      tty: true
      volumeMounts:
    • mountPath: “/opt/apache-maven-3.5.3/conf/settings.xml”
      name: “config-volume”
      subPath: “settings.xml”
    • mountPath: “/root/.sonar/cache”
      name: “volume-2”
      readOnly: false
    • mountPath: “/root/.m2”
      name: “volume-1”
      readOnly: false
    • mountPath: “/var/run/docker.sock”
      name: “volume-0”
      readOnly: false
    • mountPath: “/home/jenkins/agent”
      name: “workspace-volume”
      readOnly: false
      workingDir: “/home/jenkins/agent”
  • args:
    • “********”
    • “maven-krr0p”
      env:
    • name: “JENKINS_SECRET”
      value: “********”
    • name: “JENKINS_TUNNEL”
      value: “devops-jenkins-agent.kubesphere-devops-system:50000”
    • name: “JENKINS_AGENT_NAME”
      value: “maven-krr0p”
    • name: “JENKINS_NAME”
      value: “maven-krr0p”
    • name: “JENKINS_AGENT_WORKDIR”
      value: “/home/jenkins/agent”
    • name: “JENKINS_URL”
      value: “http://devops-jenkins.kubesphere-devops-system:80/
      image: “dockerhub.kubekey.local/ks/jenkins/inbound-agent:4.10-2”
      imagePullPolicy: “IfNotPresent”
      name: “jnlp”
      resources:
      limits:
      memory: “1536Mi”
      cpu: “500m”
      requests:
      memory: “400Mi”
      cpu: “50m”
      tty: false
      volumeMounts:
    • mountPath: “/root/.sonar/cache”
      name: “volume-2”
      readOnly: false
    • mountPath: “/root/.m2”
      name: “volume-1”
      readOnly: false
    • mountPath: “/var/run/docker.sock”
      name: “volume-0”
      readOnly: false
    • mountPath: “/home/jenkins/agent”
      name: “workspace-volume”
      readOnly: false
      nodeSelector: {}
      restartPolicy: “Never”
      securityContext:
      fsGroup: 1000
      tolerations:
  • effect: “NoSchedule”
    key: “node.kubernetes.io/ci”
    operator: “Exists”
  • effect: “PreferNoSchedule”
    key: “node.kubernetes.io/ci”
    operator: “Exists”
    volumes:
  • hostPath:
    path: “/var/run/docker.sock”
    name: “volume-0”
  • hostPath:
    path: “/var/data/jenkins_sonar_cache”
    name: “volume-2”
  • hostPath:
    path: “/var/data/jenkins_maven_cache”
    name: “volume-1”
  • emptyDir:
    medium: ""
    name: “workspace-volume”
  • configMap:
    items:
    • key: “MavenSetting”
      path: “settings.xml”
      name: “ks-devops-agent”
      name: “config-volume”

Running on maven-krr0p in /home/jenkins/agent/workspace/gjl-devn8mm7/atc-dev
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (clone code)
[Pipeline] git
The recommended git tool is: NONE
using credential gitlab

    wxwmcl 可能就是在 jenkins 和 jnlp 的连接上面。初始化git是jenkins做的。你可以找jenkins源码看下为何要1分钟左右。

    商业产品与合作咨询