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

修复RepoNotExist

parent 9d9cc7d0
...@@ -179,8 +179,7 @@ const findPipes = async function (ctx) { ...@@ -179,8 +179,7 @@ const findPipes = async function (ctx) {
} }
const getImageData = async (svcName, cluster) => { const getImageData = async (svcName, cluster) => {
const proConfig = await ProConfig.getOneProject({ project_name: svcName }, { type: 1 }) const params = { reponame: `qa-test/${svcName}` }
const params = { reponame: `qa-${proConfig.type}/${svcName}` }
const imageData = await awaitRequest({ const imageData = await awaitRequest({
url: `${config.api.tke_api}/tag`, url: `${config.api.tke_api}/tag`,
method: 'POST', method: 'POST',
...@@ -190,7 +189,7 @@ const getImageData = async (svcName, cluster) => { ...@@ -190,7 +189,7 @@ const getImageData = async (svcName, cluster) => {
}, },
body: JSON.stringify(params), body: JSON.stringify(params),
}) })
return imageData.data return imageData && imageData.data
} }
const save = async function (ctx) { const save = async function (ctx) {
...@@ -202,9 +201,9 @@ const save = async function (ctx) { ...@@ -202,9 +201,9 @@ const save = async function (ctx) {
branchInfo = branchInfo.filter(i => i.name === item.ref.name) branchInfo = branchInfo.filter(i => i.name === item.ref.name)
if (branchInfo.length > 0) { if (branchInfo.length > 0) {
let imageData = await getImageData(item.repository, data.cluster) let imageData = await getImageData(item.repository, data.cluster)
imageData = imageData.tagInfo.filter(i => i.tagName.indexOf(item.ref.name.split('-')[0]) !== -1) imageData = imageData && imageData.tagInfo.filter(i => i.tagName.indexOf(item.ref.name.split('-')[0]) !== -1)
// 如果还没有当前分支的镜像,或者提交时间比镜像制作时间晚时,触发jenkins // 如果还没有当前分支的镜像,或者提交时间比镜像制作时间晚时,触发jenkins
if (imageData.length === 0 || branchInfo[0].commit.committed_date.replace('T', ' ') > imageData[0].updateTime) { if (!imageData || imageData.length === 0 || branchInfo[0].commit.committed_date.replace('T', ' ') > imageData[0].updateTime) {
const buildData = { const buildData = {
projectName: item.repository, projectName: item.repository,
branchName: item.ref.name, branchName: item.ref.name,
......
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