Skip to content

Commit

Permalink
Merge pull request #98 from ISISComputingGroup/refresh_jenkins_jobs
Browse files Browse the repository at this point in the history
Auto-refresh jenkins jobs every minute
  • Loading branch information
Chsudeepta authored Jan 30, 2025
2 parents 1aaf561 + ecab572 commit eef587e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/components/JenkinsJobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const jenkinsColourToWebDashColour = new Map<string, string>([
["yellow", `bg-[#dddd00]`],
[
"yellow_anime",
`bg-[repeating-linear-gradient(45deg,#dddd00_0px,#dddd00_20px,#eeee00_20px,#eeee00_40px)]`,
"bg-[repeating-linear-gradient(45deg,#dddd00_0px,#dddd00_20px,#eeee00_20px,#eeee00_40px)]",
], // build running but was broken
[
"red_anime",
`bg-[repeating-linear-gradient(45deg,#F08080_0px,#F08080_20px,#F09090_20px,#F09090_40px)]`,
"bg-[repeating-linear-gradient(45deg,#F08080_0px,#F08080_20px,#F09090_20px,#F09090_40px)]",
], // build running but was broken
[
"blue_anime",
Expand All @@ -32,6 +32,7 @@ export default function JenkinsJobs() {
const [data, setData] = useState<Array<IfcWallDisplayJob>>([]);

useEffect(() => {
// initially request from jenkins, then set interval to do so every minute thereafter.
async function fetchPosts() {
const res = await fetch(
"https://epics-jenkins.isis.rl.ac.uk/view/WallDisplay/api/json",
Expand All @@ -43,6 +44,11 @@ export default function JenkinsJobs() {
setData(jobs);
}
fetchPosts();

const interval = setInterval(() => {
fetchPosts();
}, 60000);
return () => clearInterval(interval);
}, []);

if (data.length === 0) {
Expand Down

0 comments on commit eef587e

Please sign in to comment.