Shubham Yadav
Shubham Yadav

Reputation: 1

How to run cypress test cases and save generated reports on Jenkins pipeline

I have written cypress test case to compare snapshots coming through two apis. If there is any difference in both the snapshots, It should show those difference and store the test report in Jenkins workspace. I tried using reportUtils() method from jenkins library but it didn't work. Can someone please help me on this?


@Library('EnterpriseSharedLibrary') _
def utils = new com.aexp.jenkins.library.Utils()
def reportUtils = new com.aexp.jenkins.library.reportUtils()
println "Pipeline to run - ${utils.pipelineToRun}"

def branch = env.BRANCH_NAME
println "Branch - ${branch}"

node('cicd-build') {
    stage("Checkout") {
        scmCheckout {
            deleteWorkspace = 'false'
            node_version = 'Nodejs 16'
        }
    }
    stage("Install Packages") {
        env.SASS_BINARY_SITE = 'https://artifactory.aexp.com/github-node-sass/download'
        env.PHANTOMJS_CDNURL = 'https://artifactory.aexp.com/npm-remotes/ariya/phantomjs/downloads/'
        env.NODEJS_ORG_MIRROR = 'https://artifactory.aexp.com/nodejs-proxy/'
        env.CYPRESS_DOWNLOAD_MIRROR = 'https://artifactory.aexp.com/cypress-binaries/'
        npmUtils.npm 'install'
        sh "npm run test:custom"
    }
    stage("Sonar") {
        sonarscanonly {
            language = "js"
        }
    }
    stage("Archive Test Reports") {
        archiveArtifacts artifacts: 'cypress/reports/**/*',
        allowEmptyArchive: true
    }
    post {
        always {
            publishHTML(target: [
                allowMissing: true,
                alwaysLinkToLastBuild: true,
                keepAll: true,
                reportDir: 'cypress/reports/mochawesome',
                reportFiles: 'mochawesome.html',
                reportName: 'Email Test Report'
            ])
        }
    }
    stage("Save Html Reports") {
       reportUtils.publishHTMLReports()
    }
}

Upvotes: 0

Views: 26

Answers (0)

Related Questions