a50a07d690e2b29113954d25fc491c847e1092c2
configuration/createHudsonJobForBug.sh
| ... | ... | @@ -4,9 +4,12 @@ if [ $# -eq 0 ]; then |
| 4 | 4 | echo "" |
| 5 | 5 | echo |
| 6 | 6 | echo "Constructs a Hudson job for the given bugid" |
| 7 | - echo "Example: $0 4221" |
|
| 7 | + echo "Example: $0 4221 [ {Bugzilla-API-Key} ]" |
|
| 8 | 8 | echo "Builds a Hudson job for bug branch bug4221, linking to the Bugzilla bug and copying a release" |
| 9 | - echo "from Github to https://releases.sapsailing.com if the Github Actions Workflow built one" |
|
| 9 | + echo "from Github to https://releases.sapsailing.com if the Github Actions Workflow built one." |
|
| 10 | + echo "If a Bugzilla API Key is provided (may also be specified in the BUGZILLA_API_KEY environment" |
|
| 11 | + echo "variable), it is used to add the bug summary to the build job's description." |
|
| 12 | + echo "Get a Bugzilla API Key for your user account at https://bugzilla.sapsailing.com/bugzilla/userprefs.cgi?tab=apikey" |
|
| 10 | 13 | exit 2 |
| 11 | 14 | fi |
| 12 | 15 | |
| ... | ... | @@ -18,6 +21,16 @@ HUDSON_BASE_URL=https://hudson.sapsailing.com |
| 18 | 21 | BUGZILLA_BASE=https://bugzilla.sapsailing.com/bugzilla |
| 19 | 22 | COPY_TEMPLATE_JOB=CopyTemplate |
| 20 | 23 | OS_FOR_GSED="darwin" |
| 24 | +if [ -n "$2" ]; then |
|
| 25 | + BUGZILLA_API_KEY="$2" |
|
| 26 | +fi |
|
| 27 | +if [ -n "${BUGZILLA_API_KEY}" ]; then |
|
| 28 | + echo "Trying to obtain bug summary/title from Bugzilla..." |
|
| 29 | + BUG_SUMMARY="$( curl -s -H 'Content-Type: application/json' -H 'Accept: application/json' ${BUGZILLA_BASE}'/rest/bug/'${BUG_ID}'?Bugzilla_api_key='${BUGZILLA_API_KEY}'&include_fields=summary' | jq -r '.bugs[0].summary' )" |
|
| 30 | + echo "Found: ${BUG_SUMMARY}" |
|
| 31 | +else |
|
| 32 | + BUG_SUMMARY="" |
|
| 33 | +fi |
|
| 21 | 34 | read -p "Username: " USERNAME |
| 22 | 35 | read -s -p "Password: " PASSWORD |
| 23 | 36 | echo |
| ... | ... | @@ -27,9 +40,9 @@ curl -s -X GET $COPY_TEMPLATE_CONFIG_URL -u "$USERNAME:$PASSWORD" -o "$CONFIGFIL |
| 27 | 40 | # On macosx is gnu-sed needed |
| 28 | 41 | if [[ "$OSTYPE" == *"$OS_FOR_GSED"* ]]; then |
| 29 | 42 | echo "Using gsed" |
| 30 | - gsed -i'' -e 's|<description>..*</description>|<description>This is the CI job for \<a href=\"'$BUGZILLA_BASE'/show_bug.cgi?id='$BUG_ID'\"\>Bug '$BUG_ID'\</a\>. See its latest \<a href=\"/userContent/measurements.html?job=bug'$BUG_ID'\"\>quality and performance measurements here.\</a\></description>|' -e 's|<disabled>true</disabled>|<disabled>false</disabled>|' "$CONFIGFILE" |
|
| 43 | + gsed -i'' -e 's|<description>..*</description>|<description>This is the CI job for \<a href=\"'$BUGZILLA_BASE'/show_bug.cgi?id='$BUG_ID'\"\>Bug '$BUG_ID'\</a\> ('"${BUG_SUMMARY}"'). See its latest \<a href=\"/userContent/measurements.html?job=bug'$BUG_ID'\"\>quality and performance measurements here.\</a\></description>|' -e 's|<disabled>true</disabled>|<disabled>false</disabled>|' "$CONFIGFILE" |
|
| 31 | 44 | else |
| 32 | - sed -i -e 's|<description>..*</description>|<description>This is the CI job for \<a href=\"'$BUGZILLA_BASE'/show_bug.cgi?id='$BUG_ID'\"\>Bug '$BUG_ID'\</a\>. See its latest \<a href=\"/userContent/measurements.html?job=bug'$BUG_ID'\"\>quality and performance measurements here.\</a\></description>|' -e 's|<disabled>true</disabled>|<disabled>false</disabled>|' "$CONFIGFILE" |
|
| 45 | + sed -i -e 's|<description>..*</description>|<description>This is the CI job for \<a href=\"'$BUGZILLA_BASE'/show_bug.cgi?id='$BUG_ID'\"\>Bug '$BUG_ID'\</a\> ('"${BUG_SUMMARY}"'). See its latest \<a href=\"/userContent/measurements.html?job=bug'$BUG_ID'\"\>quality and performance measurements here.\</a\></description>|' -e 's|<disabled>true</disabled>|<disabled>false</disabled>|' "$CONFIGFILE" |
|
| 33 | 46 | fi |
| 34 | 47 | |
| 35 | 48 | # On macosx is gnu-sed needed |