Jenkins pipeline with pytest and allure Posted on 2021-08-05 | In Jenkins | | Use pipeline to better manage Jenkins job: 1234567891011121314151617181920212223242526272829303132333435363738394041424344 pipeline { agent { label 'jenkins_master' } parameters { string defaultValue: '/tests/', description: 'Set test suite', name: 'TestSuite', trim: true choice choices: ['qa', 'dev', 'product'], description: 'Set test run env', name: 'Environment' string defaultValue: '', description: 'Set tag to run', name: 'Tag', trim: true string defaultValue: '2', description: 'Set rerun times when failed', name: 'Rerun', trim: true string defaultValue: '1', description: 'Set multiple thread to run', name: 'Parallel', trim: true } stages { stage('Get Automaiton Code') { steps{ git credentialsId: 'xxxxxxx', url: 'https://xxx/api_automation.git' } } stage('Run Automation') { steps{ sh label: '', script: '''if [ ! $Tag ]; then pytest -s -v ${WORKSPACE}${TestSuite} --reruns ${Rerun} -n ${Parallel} --alluredir=./report/json --clean-alluredir else pytest -s -v ${WORKSPACE}${TestSuite} -m ${Tag} --reruns ${Rerun} -n ${Parallel} --alluredir=./report/json --clean-alluredir fi''' } } } post('Allure Report') { always{ script{ allure includeProperties: false, jdk: '', report: 'report/html/', results: [[path: 'report/json']] } } } } 欢迎您扫一扫上面的微信公众号,订阅我的博客! 分享创造价值,您的支持将鼓励我继续前行! Donate WeChat Pay Alipay Post author: 唐胡璐 Post link: http://izheyi.com/2021/08/05/Jenkins-pipeline-with-pytest-and-allure/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.