node {
stage('Pull source code') {
git 'https://gitee.com/seomassss/k8s.git'
}
dir('Final') {
//Maven 构建,制品上传到 Artifactory
stage('Maven build'){
def server = Artifactory.newServer url: "http://192.168.232.128:8083/artifactory", credentialsId: 'artifactoryCredential'
def rtMaven = Artifactory.newMavenBuild()
rtMaven.tool = 'maven' // Tool name from Jenkins configuration
rtMaven.deployer releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot-local', server: server
//收集构建信息
def buildInfo = Artifactory.newBuildInfo()
// server.publishBuildInfo buildInfo
rtMaven.run pom: 'pom.xml', goals: 'deploy -Dmaven.test.skip=true', buildInfo: buildInfo
server.publishBuildInfo buildInfo
}
//启动 Sonarqube 代码静态扫描
stage('Code scanning and get result'){
sh '''
mvn sonar:sonar -Dsonar.host.url=http://192.168.232.128:9000 -Dsonar.login=340a5790fb84bd4e5f8835a07d9f1295960deb21
'''
}
//启动 YAPI 接口测试
stage('API Testing'){
sh '''
curl http://localhost:3000/api/open/run_auto_test?id=11&token=b57ff23110407a89d4a81be007d6f35665772044cde1193b131a349c33aeb7ed
'''
}
//启动 Selenium UI 自动化测试
stage('Maven UI Testing'){
sh '''
mvn test
'''
}
}
}