Chore: Upgrade Jenkins-job-builder to 6.3.0
[releng/global-jjb.git] / job-cost / format-csv
1 #! /bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 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
12 set -euf
13
14 # This script can be run on a cost file (.csv) to standardize the formats of the
15 # uptime, cost & stack_cost fields.
16
17 cost_file=$1
18
19 while IFS="," read -r job_name build_number date resource uptime cost stack_cost build_result; do
20     [[ $resource == "0" ]] && resource='unknown'
21     printf "%s,%s,%s,%s,%d,%.2f,%.2f,%s\n" "$job_name" "$build_number" "$date" \
22            "$resource" "$uptime" "$cost" "$stack_cost" "$build_result"
23 done < "$cost_file"