Chore: Update common-packer to latest v0.16.5
[releng/builder.git] / jjb / generate-csit-status-report.sh
1 #!/bin/bash
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 _file = open('csit_failed_tests.txt', 'w+')
44
45 for link in links:
46     if link.img and (link.img['alt'] == 'Unstable' or
47                      link.img['alt'] == 'Failed' or
48                      link.img['alt'] == 'Aborted'):
49
50         url = link['href']
51         project = url.split('/')[3].split('-')[0]
52         _file.write("{}\\t{}{}\\n".format(project, jenkins_url, url))
53
54 _file.close()
55 EOF
56
57 virtualenv --quiet "/tmp/v/jenkins"
58 # shellcheck source=/tmp/v/jenkins/bin/activate disable=SC1091
59 source "/tmp/v/jenkins/bin/activate"
60 pip install --quiet --upgrade "pip<10.0.0" setuptools
61 pip install --quiet --upgrade tox beautifulsoup4 requests
62
63 echo python "$script" "$BUILD_URL"
64 python "$script" "$BUILD_URL"
65
66 mkdir -p "$WORKSPACE/archives"
67 mv csit_failed_tests.txt "$WORKSPACE/archives"