代码拉取完成,页面将自动刷新
#!groovy
node('maven') {
def REPOSITORY_URL='http://200.31.147.77/devops/ansible-maven-sample.git';
def REPOSITORY_CREDENTIAL_ID='git';
def GITLAB_CONNECTION='cfets-gitlab';
def SONAR_SERVER='cfets-sonar';
def artServer = Artifactory.server('artifactory');
artServer.credentialsId='GLOBAL-ARTIFACTORY';
def rtMaven = Artifactory.newMavenBuild();
rtMaven.tool = 'maven';
rtMaven.resolver server: artServer, releaseRepo: 'maven-release', snapshotRepo: 'maven-release';
rtMaven.deployer.deployArtifacts = false;
properties([
gitLabConnection("$GITLAB_CONNECTION"),
[$class: 'GitlabLogoProperty', repositoryName: ''],
[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
pipelineTriggers([[
$class: 'GitLabPushTrigger',
branchFilterType: 'All',
triggerOnPush: true,
triggerOnMergeRequest: true,
triggerOpenMergeRequestOnPush: "never",
triggerOnNoteRequest: true,
noteRegex: "Jenkins please retry a build",
skipWorkInProgressMergeRequest: true,
ciSkip: false,
setBuildDescription: true,
addNoteOnMergeRequest: true,
addCiMessage: true,
addVoteOnMergeRequest: true,
acceptMergeRequestOnSuccess: false,
]])
])
gitlabBuilds(builds: ['Checkout', 'Scan', 'Test', 'Quality Gate']){
stage('Check out'){
gitlabCommitStatus("Checkout") {
echo "branchName=$BRANCH_NAME"
echo "REPOSITORY_CREDENTIAL_ID=$REPOSITORY_CREDENTIAL_ID"
git branch: "$BRANCH_NAME", credentialsId: "$REPOSITORY_CREDENTIAL_ID", url: "$REPOSITORY_URL"
}
}
stage("SonarQube scan") {
gitlabCommitStatus("Scan") {
withSonarQubeEnv("$SONAR_SERVER") {
rtMaven.run pom:'pom.xml', goals: '-Dmaven.test.skip=true compile sonar:sonar'
}
}
}
stage('Unit Test') {
gitlabCommitStatus("Test") {
echo "=============================unit test start================================================="
rtMaven.run pom:'pom.xml', goals: 'org.jacoco:jacoco-maven-plugin:prepare-agent test'
// jacoco() //需安装jacoco插件
echo "=============================unit test end================================================="
}
}
}
}
stage("Quality Gate"){
gitlabCommitStatus("Quality Gate") {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。