diff --git a/buildinfo/admin.py b/buildinfo/admin.py
index f35c595..90a13f1 100644
--- a/buildinfo/admin.py
+++ b/buildinfo/admin.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2022 The Sipwise Team - http://sipwise.com
+# Copyright (C) 2022-2023 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
from django.contrib import admin
+from django.utils.html import format_html
from import_export import resources
from import_export.admin import ImportExportModelAdmin
@@ -33,3 +34,7 @@ class BuildInfoAdmin(ImportExportModelAdmin):
"param_distribution",
"builton",
)
+ readonly_fields = ("jenkins_url",)
+
+ def jenkins_url(self, obj):
+ return format_html("{url}", url=obj.jenkins_url)
diff --git a/buildinfo/models.py b/buildinfo/models.py
index 20c9a85..f62ace0 100644
--- a/buildinfo/models.py
+++ b/buildinfo/models.py
@@ -16,6 +16,7 @@ from typing import Any
from django.db import models
+from .conf import settings
from .utils import datetime
from .utils import get_datetime
@@ -45,6 +46,11 @@ class BuildInfo(models.Model):
param_ppa = models.CharField(max_length=50, null=True, blank=True)
objects = BuildInfoManager()
+ @property
+ def jenkins_url(self):
+ base_url = settings.JENKINS_URL
+ return f"{base_url}/jobs/{self.projectname}/{self.buildnumber}/"
+
def __str__(self):
return (
f"{self.jobname}:{self.buildnumber}:"