初次提交
This commit is contained in:
52
Jenkinsfile
vendored
Normal file
52
Jenkinsfile
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
pipeline {
|
||||
agent any
|
||||
parameters {
|
||||
// 提供要部署的环境选项
|
||||
choice(
|
||||
description: '你需要选择哪个环境进行部署 ?',
|
||||
name: 'env',
|
||||
choices: ['开发环境', '测试环境', '线上环境']
|
||||
)
|
||||
// 提供构建的模块选项
|
||||
choice(
|
||||
description: '你需要选择哪个模块进行构建 ?',
|
||||
name: 'moduleName',
|
||||
choices: ['api_gateway', 'business_service', 'data_collect_service', 'file_center', 'flowable_center', 'td_service', 'user_service', 'vpp_service', 'xxl_job', 'xxl_job_admin']
|
||||
)
|
||||
|
||||
environment {
|
||||
GIT_CREDENTIALS_ID = 'gitlab_majun' // GitLab 凭证 ID
|
||||
SONARQUBE_SERVER = 'sonarqube' // SonarQube 凭证 ID
|
||||
MAVEN_HOME = tool(name: '/app/maven') // 使用jenkins容器内映射的maven路劲
|
||||
}
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
script {
|
||||
// GitLab repository URL and branch (edit these as needed)
|
||||
def gitRepositoryUrl = 'http://192.168.100.250:7000/fanchunlei/hocloud-open.git'
|
||||
def gitBranch = 'main'
|
||||
|
||||
// 拉取代码
|
||||
git url: gitRepositoryUrl,
|
||||
branch: gitBranch,
|
||||
credentialsId: GIT_CREDENTIALS_ID
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('SonarQube Analysis') {
|
||||
steps {
|
||||
withSonarQubeEnv(SONARQUBE_SERVER) {
|
||||
// 使用 Maven 进行 SonarQube 扫描
|
||||
sh "${MAVEN_HOME}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=fanchunlei_hocloud-open_AZMjkNEoXxgoDCEPS1yf""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
// 清理工作区
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user