一、gitlab创建项目
先做后端提交,后端项目提交到本地git
定义远程仓库地址
windows本地安装TortoiseGit用来提交前端项目代码
二、Jenkins从gitlab中拉取项目源码
三、创建Jenkinsfile文件
SCM模式------使用流水线语法--------chectout-----生成代码----
回到idea-----创建Jenkinsfile----提交到gitlab
def git_auth="e6ede7de-abef-449e-be67-a9a72feb5fb2"
def git_url="git@192.168.199.131:hy/tensquare_back.git"
node {
stage('pull code') {
checkout([$class: 'GitSCM', branches: [[name: "*/${branch}"]], extensions: [], userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_url}"]]])
}
stage('check code') {
//定义SonarQubeScanner工具
def scannerHome = tool 'sonar-scanner'
//引用SonarQube系统环境
withSonarQubeEnv('sonarqube') {
sh """
cd ${project_name}
${scannerHome}/bin/sonar-scanner
"""
}
}
}
四、Jenkins直接构建流程