1.https://gitee.com/login,注册码云,记录姓名、手机或邮箱、密码;
2.新建仓库,输入仓库名,路径,新建仓库成功,分支也可新建;
3.在码云上,上传jmeter脚本test.jmx及Jenkinsfile;
4.Jenkinsfile内容如下(说明:注意修改对应路径):
pipeline {
agent any
stages {
stage('Build') {
steps {
script
{
echo "执行jmeter脚本"
bat '''D:/apache-jmeter-5.0/bin/jmeter -n -t *.jmx -l TEST_%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%.jtl'''
step([$class: 'ArtifactArchiver', artifacts: '**/*.jtl, **/jmeter.log'])
}
}
}
stage('report') {
steps {
script{
echo "转化报告格式由jtl到html"
bat '''D:/xslt/bin/xsltproc -o REPORT_%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%.html D:/apache-jmeter-5.0/extras/jmeter-results-detail-report_21.xsl TEST_%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%.jtl'''
step([$class: 'ArtifactArchiver', artifacts: '*.html', fingerprint: true])
}
}
}
}
}
5.下载git并成功安装,下载地址:https://git-scm.com/download/win
①进入.ssh目录---cd ~/.ssh/
②git config --global user.name "***"--------------------(***为码云的用户名)
③git config --global user.email "***@126.com"------------------------------(***为码云邮箱)
④ssh-keygen -t rsa -C "***@126.com"-----------------------------(***为码云邮箱)
⑤生成图片中内容,打开.pub文件,拷贝公钥内容,粘贴到码云,设置的ssh公钥中
6.jenkins新建多分支流水线
①新建Multibranch Pipeline
②Branch Sources中,点击Add source选择Git
③.在码云中,点击【克隆/下载】-->选择HTTPS,点击复制
④复制码云地址到Project Repository,Credentials中填写码云的邮箱与密码;
⑤其他样式无需填写,点击【save】
⑥最终显示执行成功。