diff --git a/config.json b/config.json index 570b3e8..3059b0e 100644 --- a/config.json +++ b/config.json @@ -18,7 +18,8 @@ "urlElectronClient": "http://localhost:5780", "urlApi": "https://dev.tombutcher.work/api", "devAuthClient": "http://localhost:3500", - "jenkinsProject": "https://ci.tombutcher.work/job/farmcontrol/job/farmcontrol-ui" + "jenkinsProject": "https://ci.tombutcher.work/job/farmcontrol/job/farmcontrol-ui", + "appUpdateStorage": "https://dist.farmcontrol.app/jenkins/farmcontrol/farmcontrol-ui" }, "database": { "mongo": { @@ -79,7 +80,8 @@ "urlElectronClient": "http://localhost:5780", "urlApi": "http://localhost:8788/api", "devAuthClient": "http://localhost:3500", - "jenkinsProject": "https://ci.tombutcher.work/job/farmcontrol/job/farmcontrol-ui" + "jenkinsProject": "https://ci.tombutcher.work/job/farmcontrol/job/farmcontrol-ui", + "appUpdateStorage": "https://dist.farmcontrol.app/jenkins/farmcontrol/farmcontrol-ui" }, "database": { "mongo": { @@ -138,7 +140,8 @@ "urlElectronClient": "http://localhost:3000", "urlApi": "https://api.farmcontrol.app", "devAuthClient": "http://localhost:3500", - "jenkinsProject": "https://ci.tombutcher.work/job/farmcontrol/job/farmcontrol-ui" + "jenkinsProject": "https://ci.tombutcher.work/job/farmcontrol/job/farmcontrol-ui", + "appUpdateStorage": "https://dist.farmcontrol.app/jenkins/farmcontrol/farmcontrol-ui" }, "database": { "mongo": { diff --git a/src/services/misc/appupdate.js b/src/services/misc/appupdate.js index d28383e..0fef98d 100644 --- a/src/services/misc/appupdate.js +++ b/src/services/misc/appupdate.js @@ -21,14 +21,14 @@ const buildApiUrl = (baseUrl, query = '') => { const getBranchBuildApiUrl = (branchUrl, buildType = 'lastSuccessfulBuild') => `${normalizeProjectUrl(branchUrl)}/${buildType}/api/json?tree=number,url,result,timestamp,artifacts[fileName,relativePath]`; -const mapArtifacts = (build) => { +const mapArtifacts = (build, requestedBranch) => { const buildUrl = normalizeProjectUrl(build?.url); const artifacts = Array.isArray(build?.artifacts) ? build.artifacts : []; console.log(artifacts); return artifacts.map((artifact) => ({ fileName: artifact.fileName, relativePath: artifact.relativePath, - url: `${buildUrl}/artifact/${artifact.relativePath}`, + url: `${config.app.appUpdateStorage}/${requestedBranch}/${build.number}/artifacts/${artifact.relativePath}`, })); }; @@ -111,7 +111,7 @@ export const appUpdateCurrentRouteHandler = async (req, res) => { buildResult: build.result, buildTimestamp: build.timestamp, buildSource: source, - artifacts: mapArtifacts(build), + artifacts: mapArtifacts(build, requestedBranch), }); } catch (error) { logger.error('Failed to fetch Jenkins build info:', error);