Bitbucket服务器个人存储库-JX升级错误:metadata.labels:无效值

时间:2019-08-06 12:30:08

标签: jenkins openshift bitbucket-server okd jenkins--x

摘要

我已经用Jenkins X导入了个人Bitbucket服务器存储库,个人存储库的组织为~my_username。当管道运行时,在jx promote步骤中出现错误:

ERROR: Error trying to create missing sourcerepository object: failed to update SourceRepository my_username-test-project: SourceRepository.jenkins.io "my_username-test-project" is invalid: metadata.labels: Invalid value: "~my_username": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

WARNING: Failed to update PipelineActivity: PipelineActivity.jenkins.io "my_username-test-project-master-1" is invalid: metadata.labels: Invalid value: "~my_username": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

error: PipelineActivity.jenkins.io "my_username-test-project-master-1" is invalid: metadata.labels: Invalid value: "~my_username": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

我已经尝试过的东西

我尝试在项目的每个位置(Jenkinsfile,Makefile,values.yaml,skaffold.yaml)中将~my_username替换为my_username,但错误仍然存​​在。

我还尝试使用jx delete application完全删除应用程序,然后再次导入,但结果相同。

Kubernetes集群

我正在OpenShift OKD 3.11本地群集(在CentOS 7 VM中运行)上运行Jenkins X平台。

JX版本

NAME               VERSION
jx                 2.0.554
jenkins x platform 2.0.880
Kubernetes cluster v1.11.0+d4cacc0
kubectl            v1.11.0+d4cacc0
helm client        Client: v2.14.2+ga8b13cc
git                git version 1.8.3.1
Operating System   "CentOS Linux release 7.6.1810 (Core) "

Jenkins X安装类型

带有Jenkinsfile的詹金斯经典版

Jenkinsfile

pipeline {
  agent {
    label "jenkins-nodejs8x"
  }
  environment {
    ORG = 'my_username'
    APP_NAME = 'test-project'
    CHARTMUSEUM_CREDS = credentials('jenkins-x-chartmuseum')
    DOCKER_REGISTRY_ORG = 'my_username'
  }
  stages {
    stage('CI Build and push snapshot') {
      when {
        branch 'PR-*'
      }
      environment {
        PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER"
        PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase()
        HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase()
      }
      steps {
        container('nodejs') {
          sh "jx step credential -s npm-token -k file -f /builder/home/.npmrc --optional=true"
          sh "npm install"
          sh "CI=true DISPLAY=:99 npm test"
          sh "npm run build"
          sh "export VERSION=$PREVIEW_VERSION && skaffold build -f skaffold.yaml"
          sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$PREVIEW_VERSION"
          dir('./charts/preview') {
            sh "make preview"
            sh "jx preview --app $APP_NAME --dir ../.."
          }
        }
      }
    }
    stage('Build Release') {
      when {
        branch 'master'
      }
      steps {
        container('nodejs') {

          // ensure we're not on a detached head
          sh "git checkout master"
          sh "git config --global credential.helper store"
          sh "jx step git credentials"

          // so we can retrieve the version in later steps
          sh "echo \$(jx-release-version) > VERSION"
          sh "jx step tag --version \$(cat VERSION)"
          sh "jx step credential -s npm-token -k file -f /builder/home/.npmrc --optional=true"
          sh "npm install"
          sh "CI=true DISPLAY=:99 npm test"
          sh "npm run build"
          sh "export VERSION=`cat VERSION` && skaffold build -f skaffold.yaml"
          sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:\$(cat VERSION)"
        }
      }
    }
    stage('Promote to Environments') {
      when {
        branch 'master'
      }
      steps {
        container('nodejs') {
          dir('./charts/software-ui-originations') {
            sh "jx step changelog --batch-mode --version v\$(cat ../../VERSION)"

            // release the helm chart
            sh "jx step helm release"

            // promote through all 'Auto' promotion Environments
            sh "jx promote -b --all-auto --timeout 1h --version \$(cat ../../VERSION)"
          }
        }
      }
    }
  }
  post {
    always {
      cleanWs()
    }
  }
}

我不知道我是否错过了某个地方的配置,或者这是Bitbucket服务器私有存储库的Jenkins X问题。

0 个答案:

没有答案