github.com/imran-kn/cilium-fork@v1.6.9/contrib/scripts/jenkins-failures.sh (about)

     1  #!/bin/bash
     2  
     3  # This script checks Jenkins master Jobs and validated that the failed jobs has
     4  # been already triaged and upstream issue has been created if it's needed.
     5  # To clean the list of Jenkins builds, build description needs to be updated with a comment.
     6  
     7  # allow users to specify SINCE as seconds since epoch
     8  YESTERDAY=$(date -d -1day)
     9  SINCE=${SINCE:-$YESTERDAY}
    10  # ensure SINCE is the correct length
    11  SINCE=$(date -d "$SINCE" +%s%N  | cut -b1-13)
    12  
    13  TAB="   "
    14  BOLD=$(tput bold)
    15  NORMAL=$(tput sgr0)
    16  BLUE=$(tput setaf 4)
    17  
    18  get_job_data () {
    19      local JOB=$1
    20      local FILTER="?tree=builds[fullDisplayName,id,number,timestamp,result,description,result]"
    21      local TEST_RESULT="/testReport/junit/api/xml?xpath=//case[status%20=%20%22REGRESSION%22]/name&wrapper=true"
    22  
    23      NO_TRIAGED_FAILURES=$(curl -s "${JOB}api/json${FILTER}" --globoff | jq -r '.builds[] | select ( .timestamp  > '$SINCE' and .result == "FAILURE" and .description == null) | .id')
    24      for build in $NO_TRIAGED_FAILURES;
    25      do
    26          echo "${BOLD}BUILD ID: ${build}${NORMAL}"
    27          echo -e "${TAB}${BOLD}${BLUE}URL${NORMAL}: ${JOB}${build}"
    28          RESULTS=$(curl -s "${JOB}/${build}/${TEST_RESULT}" --globoff)
    29          echo -e "${TAB}${BOLD}${BLUE}TEST_FAILURE${NORMAL}: \n \t${RESULTS}"
    30      done
    31  }
    32  
    33  get_job_data "https://jenkins.cilium.io/job/cilium-ginkgo/job/cilium/job/master/"
    34  get_job_data "https://jenkins.cilium.io/job/Ginkgo-CI-Tests-Pipeline/"
    35  get_job_data "https://jenkins.cilium.io/job/Cilium-Master-Nightly-Tests-All/"
    36  get_job_data "https://jenkins.cilium.io/job/cilium-ginkgo/job/cilium/job/v1.0/"