1、jenkins安装
jenkins网址:Jenkins
java采用自动检测路径,未安装,安装即可。
打开网页,url:localhost:8080
根据以下地址,取得密码
由于安装比较慢,建议手动安装,不使用推荐
创建账号和密码
localhost表示本机地址,若是按照到服务器上,则是服务器上的ip地址
到这一步安装完成
开始访问:http://localhost:8080/
默认没有任何插件和与刚刚用户一样。
2、jenkins的工作目录修改
allure测试报告展示
自动化测试流水线展示
pipeline {
agent any
stages {
stage('Windows pull hsbin') {
steps {
script {
if(fileExists('hs_hrcs-bin')) {
echo 'Updating existing repository'
dir('hs_hrcs-bin'){
// 保证每次都有变化,使得后面丢弃命令不会出错
bat "echo %date% %time% >> commitid"
bat 'git stash save --include-untracked'
bat 'git stash drop'
bat 'git pull'
}
} else {
echo 'Cloning repository'
bat 'git clone http://192.168.100.252:10101/r/artifact/hs_hrcs-bin2.git'
}
}
bat 'dir'
}
}
stage('Rename hsbin folder') {
steps {
script {
if(fileExists('hs_hrcs-bin2')) {
bat 'rename hs_hrcs-bin2 hs_hrcs-bin'
echo 'hs_hrcs-bin2 has been renamed to hs_hrcs-bin'
} else {
echo 'hs_hrcs-bin2 folder does not exist, no need to rename'
}
}
bat 'dir'
}
}
stage('git clone AutoTestScript') {
steps {
script {
if (fileExists('hs_testing_solution2.0')) {
// 保留reports和temp文件夹
bat "mkdir temp_backup"
bat "xcopy hs_testing_solution2.0\\reports temp_backup\\reports\\ /I /E /H /K /Y /R"
bat "xcopy hs_testing_solution2.0\\temp temp_backup\\temp\\ /I /E /H /K /Y /R"
dir('hs_testing_solution2.0') { deleteDir() }
bat 'git clone http://10.3.36.1:8082/hs_testing_solution2.0.git'
bat "xcopy temp_backup\\reports hs_testing_solution2.0\\reports\\ /I /E /H /K /Y /R"
bat "xcopy temp_backup\\temp hs_testing_solution2.0\\temp\\ /I /E /H /K /Y /R"
bat "rmdir /s /q temp_backup"
}
}
bat 'dir'
}
}
stage('Exec AutoTestScript All Platforms') {
parallel {
stage('AutoTestfor Linux System') {
steps {
bat 'dir'
dir('hs_testing_solution2.0') {
echo 'LinuxVersion Testing..'
bat 'python Run_Linux.py'
allure includeProperties: false, jdk: '', report: 'reports/Linux', results: [[path: 'temp/Linux']]
}
}
}
stage('AutoTestfor Window System') {
steps {
bat 'dir'
dir('hs_testing_solution2.0') {
sleep 2
//bat 'python Run_Win.py'
sleep 2
//allure includeProperties: false, jdk: '', report: 'reports/Window', results: [[path: 'temp/Window']]
}
}
}
}
}
}
}