0

Need help setting up a pipeline on jenkins. It is necessary to run tests and collect logs in parallel, it worked out, but now there is another problem, the collection of logs is not completed. Maybe there is some method how to stop a task after another task is completed?

stage('Smoke Run') {
            steps {
                parallel(
                    first: {
                        catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
                        sh '$PYTHON -m pytest --testit android_tv/tests/smoke_run/ --clean-alluredir --alluredir=/Users/jenkins/allure-report/android-tv'
                        }
                    },
                    second: {
                        sh "$ADB logcat -c"
                        sh "$ADB logcat -> ~/jenkins/workspace/Android_TV_Smoke_Run/android_tv/tests/smoke_run/logs_tv/log.log"
                    }
                )
            }
        }

1 Answers1

0

found a solution

            steps {
                script {
                    stop = false
                    parallel(
                        first: {
                            catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
                                sh '''
                                set +e
                                $PYTHON -m pytest --testit android_tv/tests/smoke_run/ --clean-alluredir --alluredir=/Users/jenkins/allure-report/android-tv
                                set -e
                                '''.stripIndent()
                                stop = true
                            }
                        },
                        second: {
                            while (!stop){
                                sleep 10
                            }
                            sh '''pgrep adb logcat | xargs kill'''
                            sh '''echo "Finish writing logs"'''
                        }
                    )
                }
            }
        }```
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 28 '22 at 11:14