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

X-ray scanning not finishing in Jenkins pipeline

我正在尝试使用 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
                }
            }
        }

管道从未完成扫描。相反,它保持空转。

这是调试这个进程的好方法吗?我想用 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 服务器实例的凭据。