Commit 1dca0342 authored by 智勇's avatar 智勇

git项目适配

parent c1f49288
...@@ -14,7 +14,7 @@ const config = require(global.configPath) ...@@ -14,7 +14,7 @@ const config = require(global.configPath)
const pipelineJenkinsBuild = async function (data) { const pipelineJenkinsBuild = async function (data) {
const { const {
projectName, branchName, type, gitUser, commitMes, timestamp, projectName, branchName, type, gitUser, commitMes,
} = data } = data
const jobName = `tke-${type}` const jobName = `tke-${type}`
const buildData = { const buildData = {
...@@ -37,7 +37,7 @@ const pipelineJenkinsBuild = async function (data) { ...@@ -37,7 +37,7 @@ const pipelineJenkinsBuild = async function (data) {
branchName, branchName,
commitMes, commitMes,
gitUser, gitUser,
gitEventTime: timestamp || moment().format('YYYY-MM-DD HH:mm:ss'), gitEventTime: moment().format('YYYY-MM-DD HH:mm:ss'),
} }
await PipeLinePush.savePipesPush(store) await PipeLinePush.savePipesPush(store)
} }
...@@ -102,8 +102,7 @@ const webhooks = async function (ctx) { ...@@ -102,8 +102,7 @@ const webhooks = async function (ctx) {
} }
const gitUser = req.user_username const gitUser = req.user_username
const commitMes = req.commits[0].message const commitMes = req.commits[req.commits - 1].messagesuccess
const timestamp = req.commits[0].timestamp
// const project = await ProConfig.getOneProject({ project_name: projectName }) // const project = await ProConfig.getOneProject({ project_name: projectName })
// if (project.sonar) { // if (project.sonar) {
...@@ -128,7 +127,7 @@ const webhooks = async function (ctx) { ...@@ -128,7 +127,7 @@ const webhooks = async function (ctx) {
if (gitObject) { if (gitObject) {
logger.info('webhooks 触发 pipeline jenkins build', projectName, branchName, req.checkout_sha) logger.info('webhooks 触发 pipeline jenkins build', projectName, branchName, req.checkout_sha)
pipelineJenkinsBuild({ pipelineJenkinsBuild({
projectName, branchName, type: gitObject.type, gitUser, commitMes, timestamp, projectName, branchName, type: gitObject.type, gitUser, commitMes,
}) })
} else { } else {
logger.info(`未查询到订阅信息->>>项目名:${projectName} 分支名:${branchName},不执行pipeline jenkins`) logger.info(`未查询到订阅信息->>>项目名:${projectName} 分支名:${branchName},不执行pipeline jenkins`)
...@@ -157,7 +156,7 @@ const getMaster = async function (ctx) { ...@@ -157,7 +156,7 @@ const getMaster = async function (ctx) {
} }
data.forEach((item) => { data.forEach((item) => {
// 再次筛选下数据 因为gitlab返回的数据是模糊查询 // 再次筛选下数据 因为gitlab返回的数据是模糊查询
if (item.name === name) { if (item.name === name || item.path === name) {
projectId = item.id projectId = item.id
} }
}) })
......
...@@ -40,7 +40,7 @@ const sendExistMail = async (data) => { ...@@ -40,7 +40,7 @@ const sendExistMail = async (data) => {
+ `GITHASH : ${data.branchHash}<br/>` + `GITHASH : ${data.branchHash}<br/>`
+ `扫描分析日期 : ${data.analysisDate}<br/>` + `扫描分析日期 : ${data.analysisDate}<br/>`
+ `查看详情 : ${config.sonarHost}/project/activity?id=${data.projectName}&&selected_date=${data.analysisDate}` + `查看详情 : ${config.sonarHost}/project/activity?id=${data.projectName}&&selected_date=${data.analysisDate}`
sendMail(data.gitUserMail, `${data.project} ${title}`, text) sendMail(data.gitUserMail, `${data.projectName} ${title}`, text)
} }
const callback = async (ctx) => { const callback = async (ctx) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment