weixin_39969257
weixin_39969257
2021-01-11 17:47

kubesphere怎么修改内置maven的setting.xml配置?

1、我想指定自己的私服仓库,如何修改setting.xml? 2、jenkins拉取代码报域名不存在如何处理? 报错信息: stderr: fatal: unable to access 'http://gitlab.devops.kubesphere.local:30080/yygk-cicd/yygk.git/': Could not resolve host: gitlab.devops.kubesphere.local

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1666)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1657)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getRemoteSymbolicReferences(CliGitAPIImpl.java:2919)
at jenkins.plugins.git.AbstractGitSCMSource.retrieveActions(AbstractGitSCMSource.java:1093)
at jenkins.scm.api.SCMSource.fetchActions(SCMSource.java:764)
at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:591)
at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:165)
at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1025)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)

[Mon Sep 16 08:06:41 UTC 2019] Finished branch indexing. Indexing took 82 ms FATAL: Failed to recompute children of project-AvNzzloBQ4MP » test-cicd

该提问来源于开源项目:kubesphere/kubesphere

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

16条回答

  • weixin_39782832 weixin_39782832 4月前

    目前临时解决方案是 在项目中提交了setting.xml 然后再构建时候指向该setting.xml 属于治标不治本,期待官方尽早解决该问题 特别的: 感谢您的解答

    点赞 评论 复制链接分享
  • weixin_39875842 weixin_39875842 4月前

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

    点赞 评论 复制链接分享
  • weixin_39875842 weixin_39875842 4月前

    This issue is being automatically closed due to inactivity.

    点赞 评论 复制链接分享
  • weixin_39969257 weixin_39969257 4月前

    setting.xml 不需要修改?我在构建maven项目的时候需要指定自己本地的仓库,这如何设置? 如下是setting.xml配置本地仓库的节点: F:\eclipse\mavenck\repository

    点赞 评论 复制链接分享
  • weixin_39969257 weixin_39969257 4月前

    setting.xml 不需要修改?我在构建maven项目的时候需要指定自己本地的仓库,这如何设置? 如下是setting.xml配置本地仓库的节点: F:\eclipse\mavenck\repository

    点赞 评论 复制链接分享
  • weixin_39964660 weixin_39964660 4月前

    需要修改jenkins-casc-config当中指定镜像的setting.xml 路径为/opt/apache-maven-3.5.3/conf/settings.xml,并自己构建新的镜像,并替换jenkins-casc-config当中的镜像名称。 (修改 jenkins-casc 后的 reload 可以参考https://kubesphere.io/docs/advanced-v2.0/zh-CN/devops/jenkins-setting/#___gatsby)

    在2.1 版本当中setting.xml将以configmap的形式进行编辑,同时也可以参考这种方式进行修改,具体可以参考 https://github.com/kubesphere/ks-installer/pull/85/files

    点赞 评论 复制链接分享
  • weixin_39706367 weixin_39706367 4月前

    目前我在用的方法是 , 自定义s2i 的基础镜像, 基础镜像中添加setting 文件 还有1种是 代码中添加.s2i文件, 在里面可以指定 仓库 可以看 demo的 那个项目 还有1种方法在工程根目录下添加.m2目录 里面放置自己的setting.xml文件

    点赞 评论 复制链接分享
  • weixin_39782832 weixin_39782832 4月前

    需要修改jenkins-casc-config当中指定镜像的setting.xml 路径为/opt/apache-maven-3.5.3/conf/settings.xml,并自己构建新的镜像,并替换jenkins-casc-config当中的镜像名称。 (修改 jenkins-casc 后的 reload 可以参考https://kubesphere.io/docs/advanced-v2.0/zh-CN/devops/jenkins-setting/#___gatsby)

    在2.1 版本当中setting.xml将以configmap的形式进行编辑,同时也可以参考这种方式进行修改,具体可以参考 https://github.com/kubesphere/ks-installer/pull/85/files

    2.1.1 中 我按照这种方案修改了jenkins-agent-config 并重新加载了配置但是依然不生效,

    点赞 评论 复制链接分享
  • weixin_39964660 weixin_39964660 4月前

    可以检查一下devops的pod,确认下cm在agent里被正确挂载

    点赞 评论 复制链接分享
  • weixin_39782832 weixin_39782832 4月前

    可以检查一下devops的pod,确认下cm在agent里被正确挂载

    就在刚才,我确认了所有的服务都处于running状态处于正常状态,但是我没有在jenkins的里面找到agent的挂载

    点赞 评论 复制链接分享
  • weixin_39782832 weixin_39782832 4月前

    可以检查一下devops的pod,确认下cm在agent里被正确挂载

    就在刚才我检查了下jenkins的挂载 似乎没有发现有挂载agent

    
    Name:         ks-jenkins-d8b7cbbdd-2jlgn
    Namespace:    kubesphere-devops-system
    Priority:     0
    Node:         node2/10.0.0.223
    Start Time:   Thu, 02 Apr 2020 03:59:25 -0400
    Labels:       app=ks-jenkins
                  chart=jenkins-0.19.0
                  component=ks-jenkins-jenkins-master
                  heritage=Tiller
                  pod-template-hash=d8b7cbbdd
                  release=ks-jenkins
    Annotations:  checksum/config: 95228f5ea09d3b77b59901c52c65636e8cc72c966c597c16b97fac8fb46132e9
                  cni.projectcalico.org/podIP: 100.108.11.194/32
                  kubesphere.io/restartedAt: 2020-04-02T08:04:07.403Z
    Status:       Running
    IP:           100.108.11.194
    IPs:
      IP:           100.108.11.194
    Controlled By:  ReplicaSet/ks-jenkins-d8b7cbbdd
    Init Containers:
      copy-default-config:
        Container ID:  docker://4df9227ac08faa7deac1de3cf16d800337fdd42fb6d89411d2d4122958ff9d19
        Image:         jenkins/jenkins:2.176.2
        Image ID:      docker-pullable://jenkins/jenkins:4fba6c0c0615b24b5530fcca0e6472b7d6256be2909a21894681e3a309a4a606
        Port:          <none>
        Host Port:     <none>
        Command:
          sh
          /var/jenkins_config/apply_config.sh
        State:          Terminated
          Reason:       Completed
          Exit Code:    0
          Started:      Thu, 02 Apr 2020 03:59:27 -0400
          Finished:     Thu, 02 Apr 2020 04:00:30 -0400
        Ready:          True
        Restart Count:  0
        Limits:
          cpu:     1
          memory:  2Gi
        Requests:
          cpu:     100m
          memory:  1500Mi
        Environment:
          JENKINS_UC_DOWNLOAD:  http://uc-jenkins-update-center
        Mounts:
          /usr/share/jenkins/ref/secrets/ from secrets-dir (rw)
          /var/jenkins_config from jenkins-config (rw)
          /var/jenkins_home from jenkins-home (rw)
          /var/jenkins_plugins from plugin-dir (rw)
          /var/run/secrets/kubernetes.io/serviceaccount from ks-jenkins-token-tg5wj (ro)
    Containers:
      ks-jenkins:
        Container ID:  docker://84067c22c099787080506698a42b0188f329c10fa0ec62fa4963bfda39fc43f3
        Image:         jenkins/jenkins:2.176.2
        Image ID:      docker-pullable://jenkins/jenkins:4fba6c0c0615b24b5530fcca0e6472b7d6256be2909a21894681e3a309a4a606
        Ports:         8080/TCP, 50000/TCP
        Host Ports:    0/TCP, 0/TCP
        Args:
          --argumentsRealm.passwd.$(ADMIN_USER)=$(ADMIN_PASSWORD)
          --argumentsRealm.roles.$(ADMIN_USER)=admin
        State:          Running
          Started:      Thu, 02 Apr 2020 04:00:31 -0400
        Ready:          True
        Restart Count:  0
        Limits:
          cpu:     1
          memory:  2Gi
        Requests:
          cpu:     100m
          memory:  1500Mi
        Environment:
          JAVA_TOOL_OPTIONS:                  -Xms512m -Xmx512m -XX:MaxRAM=2g -Dhudson.slaves.NodeProvisioner.initialDelay=20 -Dhudson.slaves.NodeProvisioner.MARGIN=50 -Dhudson.slaves.NodeProvisioner.MARGIN0=0.85 -Dhudson.model.LoadStatistics.clock=5000 -Dhudson.model.LoadStatistics.decay=0.2 -Dhudson.slaves.NodeProvisioner.recurrencePeriod=5000 -Dio.jenkins.plugins.casc.ConfigurationAsCode.initialDelay=10000 -verbose:gc -Xloggc:/var/jenkins_home/gc-%t.log -XX:NumberOfGCLogFiles=2 -XX:+UseGCLogFileRotation -XX:GCLogFileSize=100m -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintHeapAtGC -XX:+PrintGCCause -XX:+PrintTenuringDistribution -XX:+PrintReferenceGC -XX:+PrintAdaptiveSizePolicy -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+ParallelRefProcEnabled -XX:+DisableExplicitGC -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 
          JENKINS_OPTS:                       
          ADMIN_PASSWORD:                     <set to the key in secret>  Optional: false
          ADMIN_USER:                         <set to the key in secret>      Optional: false
          CASC_JENKINS_CONFIG:                /var/jenkins_home/casc_configs/jenkins.yaml
          com.sun.jndi.ldap.connect.timeout:  15000
          com.sun.jndi.ldap.read.timeout:     60000
          kubernetes.connection.timeout:      60000
          kubernetes.request.timeout:         60000
          EMAIL_SMTP_HOST:                    mail.example.com
          EMAIL_SMTP_PORT:                    465
          EMAIL_USE_SSL:                      False
          EMAIL_FROM_NAME:                    KubeSphere
          EMAIL_FROM_ADDR:                    admin.com
          EMAIL_FROM_PASS:                    P
          SONAR_ENABLED:                      true
          SONAR_RUNNER_VERSION:               3.3.0.1492
          SONAR_SERVER_URL:                   http://10.0.0.221:31274
          SONAR_AUTH_TOKEN:                   489f04d49e54e1c237d0e77263e1120e3a1a2982
        Mounts:
          /usr/share/jenkins/ref/plugins/ from plugin-dir (rw)
          /usr/share/jenkins/ref/secrets/ from secrets-dir (rw)
          /var/jenkins_config from jenkins-config (ro)
          /var/jenkins_home from jenkins-home (rw)
          /var/jenkins_home/casc_configs from casc-config (ro)
          /var/run/secrets/kubernetes.io/serviceaccount from ks-jenkins-token-tg5wj (ro)
    Conditions:
      Type              Status
      Initialized       True 
      Ready             True 
      ContainersReady   True 
      PodScheduled      True 
    Volumes:
      casc-config:
        Type:      ConfigMap (a volume populated by a ConfigMap)
        Name:      jenkins-casc-config
        Optional:  false
      jenkins-config:
        Type:      ConfigMap (a volume populated by a ConfigMap)
        Name:      ks-jenkins
        Optional:  false
      plugin-dir:
        Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
        Medium:     
        SizeLimit:  <unset>
      secrets-dir:
        Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
        Medium:     
        SizeLimit:  <unset>
      jenkins-home:
        Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
        ClaimName:  ks-jenkins
        ReadOnly:   false
      ks-jenkins-token-tg5wj:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  ks-jenkins-token-tg5wj
        Optional:    false
    QoS Class:       Burstable
    Node-Selectors:  <none>
    Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s
    Events:
      Type    Reason     Age        From               Message
      ----    ------     ----       ----               -------
      Normal  Scheduled  <unknown>  default-scheduler  Successfully assigned kubesphere-devops-system/ks-jenkins-d8b7cbbdd-2jlgn to node2
      Normal  Created    57m        kubelet, node2     Created container copy-default-config
      Normal  Pulled     57m        kubelet, node2     Container image "jenkins/jenkins:2.176.2" already present on machine
      Normal  Started    57m        kubelet, node2     Started container copy-default-config
      Normal  Pulled     56m        kubelet, node2     Container image "jenkins/jenkins:2.176.2" already present on machine
      Normal  Created    56m        kubelet, node2     Created container ks-jenkins
      Normal  Started    56m        kubelet, node2     Started container ks-jenkins
    </unknown></none></unset></unset></set></set></none></none>
    点赞 评论 复制链接分享
  • weixin_39964660 weixin_39964660 4月前

    每次运行流水线会启动一个新的pod作为agent。 这个是master不会挂载配置

    点赞 评论 复制链接分享
  • weixin_39782832 weixin_39782832 4月前

    每次运行流水线会启动一个新的pod作为agent。 这个是master不会挂载配置 根据你的建议,我去查看了最新的流水线pod 也没有发现agent配置的挂载

    
    Name:         gusteau-content-cms-latest-ixq-67j-947db0235563-job-lvx9r
    Namespace:    uc
    Priority:     0
    Node:         node3/10.0.0.222
    Start Time:   Thu, 02 Apr 2020 04:39:53 -0400
    Labels:       controller-uid=7244346e-f66f-46e7-a841-fbf8e9f669f6
                  job-name=gusteau-content-cms-latest-ixq-67j-947db0235563-job
    Annotations:  cni.projectcalico.org/podIP: 100.74.135.13/32
                  kubernetes.io/limit-ranger: LimitRanger plugin set: cpu, memory request for container s2irun; cpu, memory limit for container s2irun
    Status:       Failed
    IP:           100.74.135.13
    IPs:
      IP:           100.74.135.13
    Controlled By:  Job/gusteau-content-cms-latest-ixq-67j-947db0235563-job
    Containers:
      s2irun:
        Container ID:   docker://e25035f86c8d488a762e9fbb73d6e16f6c80edaba0af053de5930cad1cd0da33
        Image:          kubesphere/s2irun:v2.1.1
        Image ID:       docker-pullable://kubesphere/s2irun:e5de4ff712074df24ea1e7dc9fe854dc4b9dad4d03e966099df956b7102cfd02
        Port:           <none>
        Host Port:      <none>
        State:          Terminated
          Reason:       Error
          Exit Code:    1
          Started:      Thu, 02 Apr 2020 04:39:59 -0400
          Finished:     Thu, 02 Apr 2020 04:40:13 -0400
        Ready:          False
        Restart Count:  0
        Limits:
          cpu:     500m
          memory:  600Mi
        Requests:
          cpu:     10m
          memory:  10Mi
        Environment:
          S2I_CONFIG_PATH:  /etc/data/config.json
          POD_NAMESPACE:    uc (v1:metadata.namespace)
          POD_NAME:         gusteau-content-cms-latest-ixq-67j-947db0235563-job-lvx9r (v1:metadata.name)
        Mounts:
          /etc/data from config-data (ro)
          /var/run/docker.sock from docker-sock (rw)
          /var/run/secrets/kubernetes.io/serviceaccount from s2irun-token-r7cnj (ro)
    Conditions:
      Type              Status
      Initialized       True 
      Ready             False 
      ContainersReady   False 
      PodScheduled      True 
    Volumes:
      config-data:
        Type:      ConfigMap (a volume populated by a ConfigMap)
        Name:      gusteau-content-cms-latest-ixq-67j-947db0235563-configmap
        Optional:  false
      docker-sock:
        Type:          HostPath (bare host directory volume)
        Path:          /var/run/docker.sock
        HostPathType:  
      s2irun-token-r7cnj:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  s2irun-token-r7cnj
        Optional:    false
    QoS Class:       Burstable
    Node-Selectors:  <none>
    Tolerations:     node.kubernetes.io/ci:NoSchedule
                     node.kubernetes.io/ci:PreferNoSchedule
                     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s
    Events:
      Type    Reason     Age        From               Message
      ----    ------     ----       ----               -------
      Normal  Scheduled  <unknown>  default-scheduler  Successfully assigned uc/gusteau-content-cms-latest-ixq-67j-947db0235563-job-lvx9r to node3
      Normal  Pulled     21m        kubelet, node3     Container image "kubesphere/s2irun:v2.1.1" already present on machine
      Normal  Created    21m        kubelet, node3     Created container s2irun
      Normal  Started    21m        kubelet, node3     Started container s2irun
    </unknown></none></none></none>
    点赞 评论 复制链接分享
  • weixin_39782832 weixin_39782832 4月前

    我使用此功能的路径是普通项目(非流水线project)的构建镜像功能

    点赞 评论 复制链接分享
  • weixin_39964660 weixin_39964660 4月前

    https://github.com/kubesphere/s2i-java-container/tree/master/java/images/centos#centos-75-s2i-java-builder-image-with-openjdk-8

    s2i可以使用环境变量来调整构建参数,在创建s2i的高级设置中有

    点赞 评论 复制链接分享
  • weixin_39782832 weixin_39782832 4月前

    https://github.com/kubesphere/s2i-java-container/tree/master/java/images/centos#centos-75-s2i-java-builder-image-with-openjdk-8

    s2i可以使用环境变量来调整构建参数,在创建s2i的高级设置中有

    我尝试加入cm来解决该问题,但是发现在该配置中其余内容没有生效,我如何把setting.xml加入到s2i中,下面是我尝试的配置:(我怀疑很大概率是我的语法不正确,原谅我对这里的语法不是很熟悉)

    
    apiVersion: devops.kubesphere.io/v1alpha1
    kind: S2iBuilder
    metadata:
      annotations:
        kubesphere.io/repoUrl: 'https://registry.cn-hangzhou.aliyuncs.com'
        languageType: java
      finalizers:
        - s2ibuilders.finalizers.kubesphere.io
      labels:
        controller-tools.k8s.io: '1.0'
        s2i-type.kubesphere.io: s2i
      name: gusteau-content-cms-latest-ixq
      namespace: uc
    spec:
      config:
        buildVolumes:
          - 's2i_java_cache:/tmp/artifacts'
        builderImage: 'kubesphere/java-8-centos7:v2.1.0'
    
        builderPullPolicy: if-not-present
        contextDir: /
        environment:
          - name: ARTIFACT_DIR
            value: content-cms/target/
          - name: JAVA_MAX_CORE
            value: '1'
          - name: MAVEN_ARGS_APPEND
            value: '--settings /opt/settings.xml'
        export: true
        gitSecretRef:
          name: gitlab-yyp
        imageName: registry.cn-hangzhou.aliyuncs.com/gusteau/content-cms
        outputBuildResult: true
        pushAuthentication:
          secretRef:
            name: ali-dockerhub
        revisionId: dev
        runtimeArtifacts:
          - source: /deployments
        runtimeImage: 'kubesphere/java-8-runtime:v2.1.0'
        sourceUrl: 'http://10.0.0.210/gusteau/gusteau-live.git'
        tag: latest
        type: java
        volumeMounts:
          - mountPath: /opt/settings.xml
            name: settings
            subPath: settings.xml
        volumes:
          - configMap:
              items:
                - key: MavenSettings
                  path: settings.xml
              name: settings
            name: settings
    
    
    点赞 评论 复制链接分享

相关推荐