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

lbsnaicq  于 2023-03-07  发布在  Jenkins
关注(0)|答案(1)|浏览(136)

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

但是管道永远不会完成扫描,而是保持空闲。

这是一个调试这个过程的好方法吗?我想用X射线扫描构建。

vmdwslir

vmdwslir1#

这解决了我的问题

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的示例。

相关问题