X 射线扫描未在 Jenkins 管道中完成

问题描述

我正在尝试使用 Jfrog xray 扫描构建,但扫描未完成。相反,它保持空闲状态。我的流水线阶段是这样配置的

stage('Publish'){
            steps {
                rtPublishBuildInfo (
                    serverId : 'my-server',buildName : env.JOB_NAME,buildNumber : BUILD_NUMBER
                )
            }
        }

        //Scan Build Artifacts in Xray
        stage('Xray Scan') {
            steps{
                script{
                    xrayConfig = [
                        'buildName'     : env.JOB_NAME,'buildNumber'   : BUILD_NUMBER,'failBuild'     : false
                    ]
                    xrayResults = rtServer.xrayScan xrayConfig
                    echo xrayResults as String
                    sleep 10
                }
            }
        }

但是管道永远不会完成扫描。相反,它保持空闲状态。

enter image description here

是调试这个过程的好方法吗?我想用 xray 扫描构建。谢谢!

解决方法

这解决了我的问题

pipeline {
    stages {

        stage('Xray Initialization'){
            steps{
                script {
                    rtServer = Artifactory.newServer url: 'server',username: username,password: password
                    buildInfo = Artifactory.newBuildInfo()
                }
            }
        }

        stage('Build') {
            steps {
                script {
                        ***** PERFORM BUILD AND UPLOAD TO ARTIFACTIORY HERE ****
                        buildName: env.JOB_NAME,buildNumber: BUILD_NUMBER
                    )
                }
            }
        }

        stage('Configure Xray build info'){
            steps{
                rtBuildInfo (
                    buildName: "my-build",buildNumber: BUILD_NUMBER,maxBuilds: 1,maxDays: 2,doNotDiscardBuilds: ["3"],deleteBuildArtifacts: true
                )
            }
        }

        stage('Publish to Xray'){
            steps {
                rtPublishBuildInfo (
                    serverId : 'server',buildName : env.JOB_NAME,buildNumber : BUILD_NUMBER
                )
            }
        }

        //Scan Build Artifacts in Xray
        stage('Xray Scan') {
            steps{
                script{
                   xrayScan (
                        serverId :   "server",buildName    : env.JOB_NAME,buildNumber : BUILD_NUMBER,failBuild    : false
                    )
                }
            }
        }
    }
}

您需要添加用于初始化 Artifactory Server 实例的构建、上传功能和凭据。