Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
176 views
in Technique[技术] by (71.8m points)

How to run nodeJS tests with Jenkins

I am learning about Jenkins CI and using pipeline to stage my jobs. I've ran into a halt where my tests aren't running. Please take a look at my "Jenkins Images" link. As you can see its stuck in the --coverage table. Typically, if i were to run my tests on my local machine, i would have to enter wcommand to get node to run all tests; however, i don't think it would be the same in a jenkins setting

Jenkins Image

Jenkinsfile

def gv

pipeline {
    agent any
    tools {nodejs "node"}
    parameters {
        choice(name: 'VERSION', choices: ['1.1.0', '1.2.0', '1.3.0'], description: '')
        booleanParam(name: 'executeTests', defaultValue: true, description: '')
    }
    stages {
        stage("init") {
            steps {
                script {
                   gv = load "script.groovy"
                   CODE_CHANGES = gv.getGitChanges()
                }
            }
        }
        stage("build frontend") {
            steps {
                dir("client") {
                    sh 'npm install'
                    echo 'building client'
                }
            }
        }
        stage("build backend") {
            steps {
                dir("server") {
                    sh 'npm install'
                    echo 'building server...'
                }
            }
        }
        stage("test") {
            when {
                expression {
                    script {
                        env.BRANCH_NAME.toString().equals('feature-jenkins') && CODE_CHANGES == false
                    }
                }
            }
            steps {
                dir("/client") {
                    sh 'npm test'
                    echo 'testing application'
                }
            }
        }
        stage("deploy") {
            steps {
                script {
                    gv.deployApp()
                }
            }
        }
    }   
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...