jenkins k8s云 jenkinsfile配置,运行构建时jenkins console输出一直停留在‘Jenkins’ doesn’t have label ‘xxxx’阶段问题解决。

podTemplate(cloud: 'kubernetes', yaml: """
apiVersion: v1
kind: Pod
spec:
  containers:
  - name: jnlp
    image: 'ops-reg.xxx.com/ops/rancher/jenkins-jnlp-slave:3.10-1-alpine'
    args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)']
  - name: mvn
    image: ops-reg.xxx.com/ops/mvn:3.3.9
    command: ['cat']
  imagePullSecrets:
  - name: registry-secret
"""
  ) {
  def GITLAB_REGISTRY = 'ops-reg.xxx.com'
  node(POD_LABEL) {
    stage('Build Docker image') {
        git changelog: false, credentialsId: 'xxx', poll: false, url: 'https://oa-git.xxx.com/JDS/thrall.git'  //clone代码到docker-test容器中
        container('mvn') {
            stage('Build a Maven project') {
                sh "mvn -s/root/.m2/settings.xml --batch-mode -Dmaven.repo.local=/root/.m2/repository clean package"
            }
        }
    }
  }
}

在给一个java项目做ci的过程中,要使用mvn容器进行编译,在使用k8s定义pod的yaml文件中,定义要使用到的mvn容器时,缺少了tty: true参数,导致构建时在jenkins console output中,一直停留在‘Jenkins’ doesn’t have label ‘thrall_4-9w38q’。从docker命令来看,mvn容器一直在重启。

 - name: mvn
    image: ops-reg.xxx.com/ops/mvn:3.3.9
    command: ['cat']
    tty: true

将mvn容器启动参数添加上tty: true后,jenkins构建正常运行。

你可能感兴趣的:(jenkins k8s云 jenkinsfile配置,运行构建时jenkins console输出一直停留在‘Jenkins’ doesn’t have label ‘xxxx’阶段问题解决。)