Skip to content

Commit 1182ca5

Browse files
author
Jerjou Cheng
committed
Fix jenkins script.
* Fail when one of the tests fails * Deploy to different app versions * Clean up app versions in the background after each test
1 parent 284300c commit 1182ca5

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

jenkins.sh

+19-7
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,24 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
set -x
17+
set -xe
1818
shopt -s globstar
1919

20+
app_version=""
21+
2022
delete_app_version() {
21-
yes | gcloud --project="$GOOGLE_PROJECT_ID" \
22-
app versions delete "$GOOGLE_VERSION_ID"
23+
if [ -n "${app_version}" ] || [ $# -gt 0 ]; then
24+
yes | gcloud --project="${GOOGLE_PROJECT_ID}" \
25+
app versions delete "${1-${app_version}}"
26+
fi
2327
}
2428
handle_error() {
2529
errcode=$? # Remember the error code so we can exit with it after cleanup
2630

2731
# Clean up
2832
delete_app_version
2933

30-
exit $errcode
34+
exit ${errcode}
3135
}
3236
trap handle_error ERR
3337

@@ -36,10 +40,18 @@ shellcheck ./**/*.sh
3640

3741
# Find all jenkins.sh's and run them.
3842
find . -mindepth 2 -maxdepth 5 -name jenkins.sh -type f | while read path; do
43+
dir="${path%/jenkins.sh}"
44+
app_version="jenkins-${dir//[^a-z]/}"
3945
(
40-
pushd "${path%jenkins.sh}"
41-
/bin/bash ./jenkins.sh
46+
pushd "${dir}"
47+
# Need different app versions because flex can't deploy over an existing
48+
# version
49+
GOOGLE_VERSION_ID="${app_version}" /bin/bash ./jenkins.sh
50+
echo "Return code: $?"
51+
52+
# Clean up the app version in the background
53+
nohup delete_app_version "${app_version}" &
4254
)
4355
done
4456

45-
delete_app_version
57+
wait

0 commit comments

Comments
 (0)