Merge "Fixup sulfur/jdk17 verify jobs"
[releng/builder.git] / jjb / generate-csit-status-report.sh
1 #!/bin/sh
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 # Create a python script to parse a Jenkins build for sub-project status
12
13 script=$(mktemp)
14
15 cat > "$script" <<EOF
16 # SPDX-License-Identifier: EPL-1.0
17 ##############################################################################
18 # Copyright (c) 2017 The Linux Foundation and others.
19 #
20 # All rights reserved. This program and the accompanying materials
21 # are made available under the terms of the Eclipse Public License v1.0
22 # which accompanies this distribution, and is available at
23 # http://www.eclipse.org/legal/epl-v10.html
24 ##############################################################################
25
26 __author__ = 'Thanh Ha'
27
28
29 import sys
30
31 from bs4 import BeautifulSoup
32 import requests
33
34
35 build_url = sys.argv[1]
36 urlparse = requests.utils.urlparse(build_url)
37 jenkins_url = "{}://{}".format(urlparse.scheme, urlparse.netloc)
38
39 page = requests.get(build_url)
40 soup = BeautifulSoup(page.text, 'html.parser')
41 links = soup.findAll("a", { "class" : "model-link" })
42
43 with open('csit_failed_tests.txt', 'w+') as _file:
44     for link in links:
45         if link.img and (link.img['alt'] == 'Unstable' or
46                          link.img['alt'] == 'Failed' or
47                          link.img['alt'] == 'Aborted'):
48
49             url = link['href']
50             project = url.split('/')[3].split('-')[0]
51             _file.write("{}\\t{}{}\\n".format(project, jenkins_url, url))
52 EOF
53
54 python3 -m venv "/tmp/v/jenkins"
55 # shellcheck source=/tmp/v/jenkins/bin/activate disable=SC1091
56 . "/tmp/v/jenkins/bin/activate"
57 # Remove pip cache to avoid cache entry deserialization failures
58 rm -rf ~/.cache/pip/
59 pip install --quiet --upgrade pip setuptools
60 pip install --quiet --upgrade tox
61 pip install --quiet --upgrade beautifulsoup4
62 pip install --quiet --upgrade requests
63
64 echo python "$script" "$BUILD_URL"
65 python "$script" "$BUILD_URL"
66
67 mkdir -p "$WORKSPACE/archives"
68 mv csit_failed_tests.txt "$WORKSPACE/archives"