最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

selenium webdriver - Test Reports couldn't create in Jenkins Workspace and My project CICD with Docker - Stack Overflow

programmeradmin3浏览0评论
node {
    try {
        stage('Copy Project') {
            sh '''
            rm -rf DockerLoginTest
            mkdir DockerLoginTest
            cp pom.xml DockerLoginTest/
            cp -r /Users/feyzaerdogan/Desktop/cypress/DockerJenkinsLoginTest/src DockerLoginTest/src
            cd DockerLoginTest
            '''
        }
        stage('Build') {
            sh 'mvn clean install -U'
        }
        stage('Test') {
            sh 'mvn test'
        }
    } finally {
        // Bu kısım her zaman çalışır (post-always gibi)
        junit 'target/surefire-reports/*.xml'
    }
}

In a CI/CD project with Jenkins, the mvn clean install and mvn clean test commands in the terminal give successful results, but test records are not created in Jenkins. The target/surefire-plugins.xml file is not created.

node {
    try {
        stage('Copy Project') {
            sh '''
            rm -rf DockerLoginTest
            mkdir DockerLoginTest
            cp pom.xml DockerLoginTest/
            cp -r /Users/feyzaerdogan/Desktop/cypress/DockerJenkinsLoginTest/src DockerLoginTest/src
            cd DockerLoginTest
            '''
        }
        stage('Build') {
            sh 'mvn clean install -U'
        }
        stage('Test') {
            sh 'mvn test'
        }
    } finally {
        // Bu kısım her zaman çalışır (post-always gibi)
        junit 'target/surefire-reports/*.xml'
    }
}

In a CI/CD project with Jenkins, the mvn clean install and mvn clean test commands in the terminal give successful results, but test records are not created in Jenkins. The target/surefire-plugins.xml file is not created.

Share Improve this question edited Mar 16 at 21:00 Alexander Pletnev 3,6811 gold badge8 silver badges23 bronze badges asked Mar 15 at 13:50 Feyza ErdoğanFeyza Erdoğan 13 bronze badges 4
  • I'm not 100% sure on this, but I don't think you can use a try/finally without a catch block. – imgnx Commented Mar 16 at 9:08
  • I wouldn't use accents or umlauts in code; but if you must, an English translation would bring more attention to the subject. – imgnx Commented Mar 16 at 9:10
  • 1 I would advise against using try-catch-finally in pipelines, it's hiding and masking the errors. Also, I'm not sure why are you expecting that file to be created - it's not where the reports are stored (I'm not even sure it's a standard file). Finally - can you confirm that Maven actually runs any tests, and you don't override the standard report directory? – Alexander Pletnev Commented Mar 16 at 21:06
  • How could I do?What files can I share with you? – Feyza Erdoğan Commented Mar 23 at 12:00
Add a comment  | 

1 Answer 1

Reset to default 0

Instead of try/finally blocks wrapped around the full code, I suggest adding post {always {}} at the end, as well as some debug statements. This will at least allow you to see where your error is happening.

stages{
        stage('Copy Project') {
            sh '''
            rm -rf DockerLoginTest
            mkdir DockerLoginTest
            cp pom.xml DockerLoginTest/
            cp -r /Users/feyzaerdogan/Desktop/cypress/DockerJenkinsLoginTest/src DockerLoginTest/src
            cd DockerLoginTest
            '''
            echo "Copy project stage completed"
        }
        stage('Build') {
            sh 'mvn clean install -U'
            echo "Build stage completed"
        }
        stage('Test') {
            sh 'mvn test'
            echo "See if file was created"
            sh "ls target/surefire-reports"
            echo "Test stage completed"
        }
    } 
post {
     always {

        // Bu kısım her zaman çalışır (post-always gibi)
        junit 'target/surefire-reports/*.xml'
    }
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论