jenkins file 编写
pipeline { agent { label "Node_1" } parameters { string(defaultValue: 'CHT', description: '', name: 'projectKey') choice( choices:['Live','Dev'], name:'env' ) } stages { stage('Prepare env') { steps { withCredentials([usernamePassword(credentialsId: '73b4e329-4dbe-47d1-b0d0-557e67c6711a', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) { sh 'chmod +x ./Prepare_env.sh' sh './Prepare_env.sh $USERNAME $PASSWORD' } } } stage('Start run test cases on Live') { when {expression { return params.env == 'Live'} } steps { echo " The environment is ${params.env}" sh '/usr/local/python3/bin/python3 -m venv /home/local/FARFETCH/amy.zhang/automation_venv' sh 'source /home/local/FARFETCH/amy.zhang/automation_venv/bin/activate' sh 'chmod +x ./Run_allure.sh' sh "./Run_allure.sh https://storm.farfetch-apps.com/OrderProcessing/Returns" } } stage('Start run test cases on Dev') { when {expression { return params.env == 'Dev'} } steps { echo " The environment is ${params.env}" sh '/usr/local/python3/bin/python3 -m venv /home/local/FARFETCH/amy.zhang/automation_venv' sh 'source /home/local/FARFETCH/amy.zhang/automation_venv/bin/activate' sh 'chmod +x ./Run_allure_dev.sh' sh "./Run_allure_dev.sh https://storm.farfetch-apps.com/OrderProcessing/Returns" } } } // post { // always { // script { // sh 'find . -name "*.feature" | xargs rm -rf' // allure([includeProperties: false, jdk: '', properties: [], reportBuildPolicy: 'ALWAYS', results: [[path: '/**/allure-results/']]]) // } // slackSend channel: 'U22SRLXNV UU314JZBP U66UGL45B', // color:'#439FE0', // notifyCommitters: true , // message: "The pipeline ${currentBuild.fullDisplayName} build ${currentBuild.result}. The detail please check: ${env.BUILD_URL}allure ." // // } // unstable { // slackSend channel: 'U22SRLXNV UU314JZBP', // color: 'warning', // message: "The pipeline ${currentBuild.fullDisplayName} build failed." // } // } }
1.
Run_allure.sh
rm -rf ./allure-results/
export PYTHONPATH=$(pwd)
behave --tags="@Smoke" --format=cucumber_json:PrettyCucumberJSONFormatter -o cucumber.json --format allure_behave.formatter:AllureFormatter -o ./allure-results/ -D url=$1