Skip to content

Commit 88d8659

Browse files
committed
typo
1 parent fbb5059 commit 88d8659

2 files changed

Lines changed: 132 additions & 128 deletions

File tree

Jenkinsfile

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,78 +1113,80 @@ EOF
11131113
###################### */
11141114
post {
11151115
always {
1116-
if (env.EXIT_STATUS != "ABORTED"){
1117-
if (currentBuild.currentResult != "SUCCESS"){
1118-
if (env.GITHUBIMAGE =~ /lspipepr/){
1119-
if (env.CI_TEST_ATTEMPTED == "true"){
1120-
sh '''#! /bin/bash
1121-
# Function to retrieve JSON data from URL
1122-
get_json() {
1123-
local url="$1"
1124-
local response=$(curl -s "$url")
1125-
if [ $? -ne 0 ]; then
1126-
echo "Failed to retrieve JSON data from $url"
1127-
return 1
1128-
fi
1129-
local json=$(echo "$response" | jq .)
1130-
if [ $? -ne 0 ]; then
1131-
echo "Failed to parse JSON data from $url"
1132-
return 1
1133-
fi
1134-
echo "$json"
1135-
}
1116+
script {
1117+
if (env.EXIT_STATUS != "ABORTED"){
1118+
if (currentBuild.currentResult != "SUCCESS"){
1119+
if (env.GITHUBIMAGE =~ /lspipepr/){
1120+
if (env.CI_TEST_ATTEMPTED == "true"){
1121+
sh '''#! /bin/bash
1122+
# Function to retrieve JSON data from URL
1123+
get_json() {
1124+
local url="$1"
1125+
local response=$(curl -s "$url")
1126+
if [ $? -ne 0 ]; then
1127+
echo "Failed to retrieve JSON data from $url"
1128+
return 1
1129+
fi
1130+
local json=$(echo "$response" | jq .)
1131+
if [ $? -ne 0 ]; then
1132+
echo "Failed to parse JSON data from $url"
1133+
return 1
1134+
fi
1135+
echo "$json"
1136+
}
11361137
1137-
build_table() {
1138-
local data="$1"
1138+
build_table() {
1139+
local data="$1"
11391140
1140-
# Get the keys in the JSON data
1141-
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1141+
# Get the keys in the JSON data
1142+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
11421143
1143-
# Check if keys are empty
1144-
if [ -z "$keys" ]; then
1145-
echo "JSON report data does not contain any keys or the report does not exist."
1146-
return 1
1147-
fi
1144+
# Check if keys are empty
1145+
if [ -z "$keys" ]; then
1146+
echo "JSON report data does not contain any keys or the report does not exist."
1147+
return 1
1148+
fi
11481149
1149-
# Build table header
1150-
local header="| Tag | Passed |\\n| --- | --- |\\n"
1150+
# Build table header
1151+
local header="| Tag | Passed |\\n| --- | --- |\\n"
11511152
1152-
# Loop through the JSON data to build the table rows
1153-
local rows=""
1154-
for build in $keys; do
1155-
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1156-
if [ "$status" = "true" ]; then
1157-
status="✅"
1158-
else
1159-
status="❌"
1160-
fi
1161-
local row="| "$build" | "$status" |\\n"
1162-
rows="${rows}${row}"
1163-
done
1153+
# Loop through the JSON data to build the table rows
1154+
local rows=""
1155+
for build in $keys; do
1156+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1157+
if [ "$status" = "true" ]; then
1158+
status="✅"
1159+
else
1160+
status="❌"
1161+
fi
1162+
local row="| "$build" | "$status" |\\n"
1163+
rows="${rows}${row}"
1164+
done
11641165
1165-
local table="${header}${rows}"
1166-
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1167-
echo "$escaped_table"
1168-
}
1166+
local table="${header}${rows}"
1167+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1168+
echo "$escaped_table"
1169+
}
11691170
1170-
if [[ "${CI}" = "true" ]]; then
1171-
# Retrieve JSON data from URL
1172-
data=$(get_json "$CI_JSON_URL")
1173-
# Create table from JSON data
1174-
table=$(build_table "$data")
1175-
echo -e "$table"
1171+
if [[ "${CI}" = "true" ]]; then
1172+
# Retrieve JSON data from URL
1173+
data=$(get_json "$CI_JSON_URL")
1174+
# Create table from JSON data
1175+
table=$(build_table "$data")
1176+
echo -e "$table"
11761177
1177-
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1178-
-H "Accept: application/vnd.github.v3+json" \
1179-
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1180-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1181-
else
1182-
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1183-
-H "Accept: application/vnd.github.v3+json" \
1184-
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1185-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1186-
fi
1187-
'''
1178+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1179+
-H "Accept: application/vnd.github.v3+json" \
1180+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1181+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1182+
else
1183+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1184+
-H "Accept: application/vnd.github.v3+json" \
1185+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1186+
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1187+
fi
1188+
'''
1189+
}
11881190
}
11891191
}
11901192
}

ansible/roles/repository/templates/Jenkinsfile.j2

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,78 +1545,80 @@ EOF
15451545
###################### */
15461546
post {
15471547
always {
1548-
if (env.EXIT_STATUS != "ABORTED"){
1549-
if (currentBuild.currentResult != "SUCCESS"){
1550-
if (env.GITHUBIMAGE =~ /lspipepr/){
1551-
if (env.CI_TEST_ATTEMPTED == "true"){
1552-
sh '''#! /bin/bash
1553-
# Function to retrieve JSON data from URL
1554-
get_json() {
1555-
local url="$1"
1556-
local response=$(curl -s "$url")
1557-
if [ $? -ne 0 ]; then
1558-
echo "Failed to retrieve JSON data from $url"
1559-
return 1
1560-
fi
1561-
local json=$(echo "$response" | jq .)
1562-
if [ $? -ne 0 ]; then
1563-
echo "Failed to parse JSON data from $url"
1564-
return 1
1565-
fi
1566-
echo "$json"
1567-
}
1548+
script {
1549+
if (env.EXIT_STATUS != "ABORTED"){
1550+
if (currentBuild.currentResult != "SUCCESS"){
1551+
if (env.GITHUBIMAGE =~ /lspipepr/){
1552+
if (env.CI_TEST_ATTEMPTED == "true"){
1553+
sh '''#! /bin/bash
1554+
# Function to retrieve JSON data from URL
1555+
get_json() {
1556+
local url="$1"
1557+
local response=$(curl -s "$url")
1558+
if [ $? -ne 0 ]; then
1559+
echo "Failed to retrieve JSON data from $url"
1560+
return 1
1561+
fi
1562+
local json=$(echo "$response" | jq .)
1563+
if [ $? -ne 0 ]; then
1564+
echo "Failed to parse JSON data from $url"
1565+
return 1
1566+
fi
1567+
echo "$json"
1568+
}
15681569

1569-
build_table() {
1570-
local data="$1"
1570+
build_table() {
1571+
local data="$1"
15711572

1572-
# Get the keys in the JSON data
1573-
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1573+
# Get the keys in the JSON data
1574+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
15741575

1575-
# Check if keys are empty
1576-
if [ -z "$keys" ]; then
1577-
echo "JSON report data does not contain any keys or the report does not exist."
1578-
return 1
1579-
fi
1576+
# Check if keys are empty
1577+
if [ -z "$keys" ]; then
1578+
echo "JSON report data does not contain any keys or the report does not exist."
1579+
return 1
1580+
fi
15801581

1581-
# Build table header
1582-
local header="| Tag | Passed |\\n| --- | --- |\\n"
1582+
# Build table header
1583+
local header="| Tag | Passed |\\n| --- | --- |\\n"
15831584

1584-
# Loop through the JSON data to build the table rows
1585-
local rows=""
1586-
for build in $keys; do
1587-
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1588-
if [ "$status" = "true" ]; then
1589-
status="✅"
1590-
else
1591-
status="❌"
1592-
fi
1593-
local row="| "$build" | "$status" |\\n"
1594-
rows="${rows}${row}"
1595-
done
1585+
# Loop through the JSON data to build the table rows
1586+
local rows=""
1587+
for build in $keys; do
1588+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1589+
if [ "$status" = "true" ]; then
1590+
status="✅"
1591+
else
1592+
status="❌"
1593+
fi
1594+
local row="| "$build" | "$status" |\\n"
1595+
rows="${rows}${row}"
1596+
done
15961597

1597-
local table="${header}${rows}"
1598-
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1599-
echo "$escaped_table"
1600-
}
1598+
local table="${header}${rows}"
1599+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1600+
echo "$escaped_table"
1601+
}
16011602

1602-
if [[ "${CI}" = "true" ]]; then
1603-
# Retrieve JSON data from URL
1604-
data=$(get_json "$CI_JSON_URL")
1605-
# Create table from JSON data
1606-
table=$(build_table "$data")
1607-
echo -e "$table"
1603+
if [[ "${CI}" = "true" ]]; then
1604+
# Retrieve JSON data from URL
1605+
data=$(get_json "$CI_JSON_URL")
1606+
# Create table from JSON data
1607+
table=$(build_table "$data")
1608+
echo -e "$table"
16081609

1609-
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1610-
-H "Accept: application/vnd.github.v3+json" \
1611-
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1612-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1613-
else
1614-
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1615-
-H "Accept: application/vnd.github.v3+json" \
1616-
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1617-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1618-
fi
1619-
'''
1610+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1611+
-H "Accept: application/vnd.github.v3+json" \
1612+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1613+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1614+
else
1615+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1616+
-H "Accept: application/vnd.github.v3+json" \
1617+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1618+
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1619+
fi
1620+
'''
1621+
}
16201622
}
16211623
}
16221624
}

0 commit comments

Comments
 (0)