Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jenkins script. #540

Merged
merged 1 commit into from
Mar 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -x
set -xe
shopt -s globstar

app_version=""

delete_app_version() {
yes | gcloud --project="$GOOGLE_PROJECT_ID" \
app versions delete "$GOOGLE_VERSION_ID"
if [ -n "${app_version}" ] || [ $# -gt 0 ]; then
yes | gcloud --project="${GOOGLE_PROJECT_ID}" \
app versions delete "${1-${app_version}}"
fi
}
handle_error() {
errcode=$? # Remember the error code so we can exit with it after cleanup

# Clean up
delete_app_version

exit $errcode
exit ${errcode}
}
trap handle_error ERR

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

# Find all jenkins.sh's and run them.
find . -mindepth 2 -maxdepth 5 -name jenkins.sh -type f | while read path; do
dir="${path%/jenkins.sh}"
app_version="jenkins-${dir//[^a-z]/}"
(
pushd "${path%jenkins.sh}"
/bin/bash ./jenkins.sh
pushd "${dir}"
# Need different app versions because flex can't deploy over an existing
# version
GOOGLE_VERSION_ID="${app_version}" /bin/bash ./jenkins.sh
echo "Return code: $?"

# Clean up the app version in the background
nohup delete_app_version "${app_version}" &
)
done

delete_app_version
wait