Jenkins管道(工作流程)阶段视图消失

Ser*_*fel 9 jenkins jenkins-workflow jenkins-pipeline

我有问题,在一些Jenkins管道项目中,舞台视图变得不可见.

通常,您可以看到"最近更改"和"永久链接"之间的阶段视图.在一些项目运行后,舞台视图消失.如果我克隆项目,则视图在克隆中可见,但在原始项目中不可见.

这是克隆项目的一种解决方法,但不是一个好的,因为我不能每周替换这份工作.

有人曾经看过这个问题并且有想法,如何解决这个问题?

舞台视图div位于作业概述页面上,但它不可见:

<div class="cbwf-stage-view">
    <div class="cbwf-widget cbwf-controller-applied pipeline-staged" objecturl="/user/myname/my-views/view/MaintainedByMe/job/Category/job/ProjectName/" fragcaption="Stage View" cbwf-controller="pipeline-staged"></div>
    <link rel="stylesheet" href="/adjuncts/ee6b655e/org/jenkinsci/pipeline/stageview_adjunct.css" type="text/css">
    <script src="/adjuncts/ee6b655e/org/jenkinsci/pipeline/stageview_adjunct.js" type="text/javascript"></script>
</div>
Run Code Online (Sandbox Code Playgroud)

我的詹金斯文件:

def sonarHostUrl = 'http://sonar.host.url:1234'

node('Build') {
    echo "enforce a clear workspace:" // because there were some other problems
    deleteDir()

    stage('Checkout') {
        checkoutFromSVN()
    }
    stage('Compile') {
        mvn 'clean compile test-compile'
    }
    stage('Unit Tests') {
        mvn '-B org.jacoco:jacoco-maven-plugin:prepare-agent test'
        step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
    }
    stage('Deploy to Nexus') {
        mvn 'install deploy -DskipTests'
        archiveArtifacts artifacts: '**/project-name*.jar', onlyIfSuccessful: false
    }
    stage('Local Integration Tests') {
        mvn '-B org.jacoco:jacoco-maven-plugin:prepare-agent-integration failsafe:integration-test failsafe:verify'
        step([$class: 'JUnitResultArchiver', testResults: '**/target/failsafe-reports/TEST-*.xml'])
    }
    stage('Sonar'){
        mvn "org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1:sonar -Dsonar.host.url=$sonarHostUrl"
    }
}
stage('Deploy to DEV') {
    build 'JobThatDeploysTheApplicationToDevEnv'
}
stage('Functional Tests') {
    build job: 'JobWithSoapUITests', parameters: [string(name: 'TESTENVIRONMENT', value: 'DEV')]
}

def checkoutFromSVN(){
    checkout([$class: 'SubversionSCM', 
            excludedCommitMessages: '.*\\[maven-release-plugin\\].*',
            locations: [[credentialsId: 'a1a2b3c4-1234-ab1d-b56c-0ac4bff23a6c', 
                       depthOption: 'infinity', 
                       ignoreExternalsOption: true, 
                       excludedRegions: 'Jenkinsfile',
                       local: 'project-dir', 
                       remote: 'https://url.to/project-dir']], 
            workspaceUpdater: [$class: 'CheckoutUpdater']])
}

def mvn(String args) {
    def mvnCmd = "${tool name: 'Maven 3.3.9', type: 'hudson.tasks.Maven$MavenInstallation'}/bin/mvn"

    wrap([$class: 'ConfigFileBuildWrapper', 
          managedFiles: [[
                    fileId: 'org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig1234567', 
                    targetLocation: '', // temporary file
                    variable: 'MAVEN_SETTINGS']]]) {
        bat "${mvnCmd} -s ${env.MAVEN_SETTINGS} ${args} -f project-dir/pom.xml"
    }
}
Run Code Online (Sandbox Code Playgroud)

我的作业配置导出为XML:

<?xml version='1.0' encoding='UTF-8'?>
<flow-definition plugin="workflow-job@2.9">
  <actions/>
  <description></description>
  <keepDependencies>false</keepDependencies>
  <properties>
    <jenkins.model.BuildDiscarderProperty>
      <strategy class="hudson.tasks.LogRotator">
        <daysToKeep>-1</daysToKeep>
        <numToKeep>10</numToKeep>
        <artifactDaysToKeep>-1</artifactDaysToKeep>
        <artifactNumToKeep>-1</artifactNumToKeep>
      </strategy>
    </jenkins.model.BuildDiscarderProperty>
    <org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
      <triggers>
        <hudson.triggers.TimerTrigger>
          <spec>H H * * *</spec>
        </hudson.triggers.TimerTrigger>
        <hudson.triggers.SCMTrigger>
          <spec>H/10 7-18 * * *</spec>
          <ignorePostCommitHooks>false</ignorePostCommitHooks>
        </hudson.triggers.SCMTrigger>
      </triggers>
    </org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
  </properties>
  <definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@2.23">
    <scm class="hudson.scm.SubversionSCM" plugin="subversion@2.6">
      <locations>
        <hudson.scm.SubversionSCM_-ModuleLocation>
          <remote>https://url.to/project-dir</remote>
          <credentialsId>a1a2b3c4-1234-ab1d-b56c-0ac4bff23a6c</credentialsId>
          <local>.</local>
          <depthOption>infinity</depthOption>
          <ignoreExternalsOption>true</ignoreExternalsOption>
        </hudson.scm.SubversionSCM_-ModuleLocation>
      </locations>
      <excludedRegions></excludedRegions>
      <includedRegions>Jenkinsfile</includedRegions>
      <excludedUsers></excludedUsers>
      <excludedRevprop></excludedRevprop>
      <excludedCommitMessages></excludedCommitMessages>
      <workspaceUpdater class="hudson.scm.subversion.UpdateWithRevertUpdater"/>
      <ignoreDirPropChanges>false</ignoreDirPropChanges>
      <filterChangelog>false</filterChangelog>
    </scm>
    <scriptPath>Jenkinsfile</scriptPath>
  </definition>
  <triggers/>
</flow-definition>
Run Code Online (Sandbox Code Playgroud)

小智 5

我通过手动将丢失的文件复制到 Jenkins 服务器作业解决了这个问题。

我的详细步骤:

  1. 打开管道页面。
  2. 在 Chrome 中按 F12。
  3. 检查控制台是否有错误。

我的错误是缺少“ \jobs\Dev-Linux-UI\builds\21\workflow\3.xml ”,我从builds\20\workflow\3.xml复制了文件。

由于 Jenkins 管道不够稳定,该文件似乎在复制过程中丢失了。

  • 至少在旧版本的 Jenkins 上,重命名 Jenkins 作业时可能会发生这种情况。恢复作业的名称(并根据需要创建一个单独的作业)应该可以修复它。 (3认同)

Cli*_*man 3

当我看到它时,是在重新启动詹金斯之后。如果您在浏览器中查看调试器,您会发现它正在尝试加载不存在的文件。我已为此提交了一个错误,但没有回复。如果您仍然看到它,请投票:https ://issues.jenkins-ci.org/browse/JENKINS-39143

  • 对我来说也是一样,缺少一些“stageview_adjunst.js”。只需重新启动詹金斯,一切都很好:) (3认同)