Repository: archiva-redback-core
Updated Branches:
  refs/heads/master 17cf8e11c -> daa787d71


CI Build script for workspace cleanup


Project: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/commit/daa787d7
Tree: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/tree/daa787d7
Diff: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/diff/daa787d7

Branch: refs/heads/master
Commit: daa787d7195ccf487c3a602b3e73d8cee82b075f
Parents: 17cf8e1
Author: Martin Stockhammer <[email protected]>
Authored: Wed May 24 22:48:24 2017 +0200
Committer: Martin Stockhammer <[email protected]>
Committed: Wed May 24 22:48:24 2017 +0200

----------------------------------------------------------------------
 src/ci/env/build-info.txt          |  1 +
 src/ci/scripts/prepareWorkspace.sh | 49 +++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/daa787d7/src/ci/env/build-info.txt
----------------------------------------------------------------------
diff --git a/src/ci/env/build-info.txt b/src/ci/env/build-info.txt
new file mode 100644
index 0000000..51bc15b
--- /dev/null
+++ b/src/ci/env/build-info.txt
@@ -0,0 +1 @@
+CIBUILD=1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/daa787d7/src/ci/scripts/prepareWorkspace.sh
----------------------------------------------------------------------
diff --git a/src/ci/scripts/prepareWorkspace.sh 
b/src/ci/scripts/prepareWorkspace.sh
new file mode 100644
index 0000000..b3af7f3
--- /dev/null
+++ b/src/ci/scripts/prepareWorkspace.sh
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#
+#  Author: Martin Stockhammer <[email protected]>
+#  Date:   2017-05-24
+#
+#  Clears the workspace, if the build number is higher
+#  for automatic workspace cleanup on the build slaves
+#
+#  To request a workspace cleanup increase the number for CIBUILD
+#  in the file ../env/build-info.txt and
+
+## 
+BUILDINFO_DIR=${WORKSPACE}/ci
+BUILDINFO_FILE=${BUILDINFO_DIR}/buildinfo.sh
+REQ_BUILDINFO_FILE=$(dirname $0)/../env/build-info.txt
+git checkout ${REQ_BUILDINFO_FILE}
+if [ -f ${REQ_BUILDINFO_FILE} ]; then
+  . ${REQ_BUILDINFO_FILE}
+else
+  CIBUILD=0
+fi
+REQUESTED_BUILD=${CIBUILD}
+CIBUILD=0
+if [ -f ${BUILDINFO_FILE} ]; then
+  . ${BUILDINFO_FILE}
+fi
+if [ ${CIBUILD} -lt ${REQUESTED_BUILD} ]; then
+  echo "Clearing workspace"
+  rm -rf ${WORKSPACE}/*
+  mkdir -p ${BUILDINFO_DIR}
+  echo "CIBUILD=${REQUESTED_BUILD}" >${BUILDINFO_FILE}
+fi

Reply via email to