[atlassian] Improve scripts

Replace jira and confluence script by a single atlassian-versions script

Also update the atlassian_eol so that:

- Pages are now fetched using Javascript,
- The regex also accept EOS in additional to EOL,
- The full identifier is now required as a parameter (this will make it easier if the name changes again).
This commit is contained in:
Marc Wrobel
2025-03-24 09:45:26 +01:00
parent b2c37b0643
commit 8f411b9479
4 changed files with 31 additions and 37 deletions

View File

@@ -5,24 +5,24 @@ import sys
from bs4 import BeautifulSoup
from common import dates, endoflife, http, releasedata
"""Fetches EOL dates Atlassian EOL page.
"""Fetches EOL dates from Atlassian EOL page.
The only needed argument is the last part of the product title identifier on the Atlassian EOL page,
such as `JiraSoftware` (from `AtlassianSupportEndofLifePolicy-JiraSoftware`).
This script takes a single argument which is the product title identifier on the Atlassian EOL page, such as
`AtlassianSupportEndofLifePolicy-JiraSoftware`.
"""
METHOD = "atlassian_eol"
REGEX = r"(?P<release>\d+(\.\d+)+) \(EOL date: (?P<date>.+)\).*$"
REGEX = r"(?P<release>\d+(\.\d+)+) \(EO[SL] date: (?P<date>.+)\).*$"
PATTERN = re.compile(REGEX, re.MULTILINE)
p_filter = sys.argv[1] if len(sys.argv) > 1 else None
m_filter = sys.argv[2] if len(sys.argv) > 2 else None
for config in endoflife.list_configs(p_filter, METHOD, m_filter):
with releasedata.ProductData(config.product) as product_data:
response = http.fetch_url('https://confluence.atlassian.com/support/atlassian-support-end-of-life-policy-201851003.html')
soup = BeautifulSoup(response.text, features="html5lib")
content = http.fetch_javascript_url('https://confluence.atlassian.com/support/atlassian-support-end-of-life-policy-201851003.html')
soup = BeautifulSoup(content, features="html5lib")
for li in soup.select(f"#AtlassianSupportEndofLifePolicy-{config.url}+ul li"):
for li in soup.select(f"#{config.url}+ul li"):
match = PATTERN.match(li.get_text(strip=True))
if not match:
logging.warning(f"Failed to parse EOL date from '{li.get_text(strip=True)}'")

24
src/atlassian_versions.py Normal file
View File

@@ -0,0 +1,24 @@
import sys
from bs4 import BeautifulSoup
from common import dates, endoflife, http, releasedata
"""Fetches versions from Atlassian download-archives pages.
This script takes a single argument which is the url of the product's download-archives URL, such as
`https://www.atlassian.com/software/confluence/download-archives`.
"""
METHOD = "atlassian_versions"
p_filter = sys.argv[1] if len(sys.argv) > 1 else None
m_filter = sys.argv[2] if len(sys.argv) > 2 else None
for config in endoflife.list_configs(p_filter, METHOD, m_filter):
with releasedata.ProductData(config.product) as product_data:
content = http.fetch_javascript_url(config.url, wait_until='networkidle')
soup = BeautifulSoup(content, 'html5lib')
for version_block in soup.select('.versions-list'):
version = version_block.select_one('a.product-versions').attrs['data-version']
date = dates.parse_date(version_block.select_one('.release-date').text)
product_data.declare_version(version, date)

View File

@@ -1,15 +0,0 @@
from bs4 import BeautifulSoup
from common import dates, http, releasedata
"""Fetches Confluence versions from www.atlassian.com.
Note that requests_html is used because JavaScript is needed to render the page."""
with releasedata.ProductData("confluence") as product_data:
content = http.fetch_javascript_url("https://www.atlassian.com/software/confluence/download-archives")
soup = BeautifulSoup(content, 'html.parser')
for version_block in soup.select('.versions-list'):
version = version_block.select_one('a.product-versions').attrs['data-version']
date = dates.parse_date(version_block.select_one('.release-date').text)
product_data.declare_version(version, date)

View File

@@ -1,15 +0,0 @@
from bs4 import BeautifulSoup
from common import dates, http, releasedata
"""Fetches Jira versions from www.atlassian.com.
Note that requests_html is used because JavaScript is needed to render the page."""
with releasedata.ProductData("jira") as product_data:
content = http.fetch_javascript_url("https://www.atlassian.com/software/jira/update")
soup = BeautifulSoup(content, 'html.parser')
for version_block in soup.select('.versions-list'):
version = version_block.select_one('a.product-versions').attrs['data-version']
date = dates.parse_date(version_block.select_one('.release-date').text)
product_data.declare_version(version, date)