Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Continue build procedure cleanup
$tag is now defined in common.bash and used throughout building scripts.
The goal is to allow building and testing both from Jenkins and standalone.

build.sh is now more generic; allows rebuilding if -r is specified.
mederly committed Oct 5, 2018
1 parent 3b8dcd8 commit 4947aa1
Showing 6 changed files with 41 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
@@ -1,5 +1,5 @@
#
# Building assumes midpoint-3.9-SNAPSHOT-dist.tar.gz is present in the current directory.
# Building assumes midpoint-dist.tar.gz is present in the current directory.
#

FROM tier/shibboleth_sp
13 changes: 5 additions & 8 deletions Jenkinsfile
@@ -27,21 +27,18 @@ pipeline {
sh 'ls'
sh 'mv bin/* ../bin/.'
}
sh "echo \"tag=\\\"${tag}\\\"\" > tag.bash ; chmod a+x tag.bash ; echo tag.bash ; cat tag.bash'
// Build and test scripts expect that 'tag' is present in common.bash. This is necessary for both Jenkins and standalone testing.
// We don't care if there are more 'tag' assignments there. The latest one wins.
sh "echo >> common.bash ; echo \"tag=\\\"${tag}\\\"\" >> common.bash ; echo common.bash ; cat common.bash'
}
}
}
stage ('Build') {
steps {
script {
try {
if (env.BRANCH_NAME == "master") {
toDownload = "3.9-SNAPSHOT"
} else {
toDownload = env.BRANCH_NAME
}
sh "./download-midpoint ${toDownload} 2>&1 | tee -a debug ; test \${PIPESTATUS[0]} -eq 0"
sh './jenkins-rebuild.sh 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' // temporary
// using custom ./build.sh instead of bin/rebuild.sh because the bin/ version does not support building specific tag yet
sh './build.sh -r 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0'
} catch (error) {
def error_details = readFile('./debug')
def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}"
31 changes: 25 additions & 6 deletions build.sh
@@ -1,16 +1,35 @@
#!/bin/bash

cd "$(dirname "$0")"
source common.bash

SKIP_DOWNLOAD=0
while getopts "nh?" opt; do
while getopts "nhr?" opt; do
case $opt in
n) SKIP_DOWNLOAD=1 ;;
h | ?) echo "Options: -n skip download" ; exit 0 ;;
*) echo "Unknown option: $opt" ; exit 1 ;;
n)
SKIP_DOWNLOAD=1
;;
r)
result=$(docker ps -a | grep $maintainer/$imagename:$tag)
if [ ! -z "$result" ]; then
echo "Cleaning up $maintainer/$imagename:$tag..."
docker rm -f $(docker ps -a | grep $maintainer/$imagename:$tag | awk '{print $1}')
docker rmi -f $maintainer/$imagename:$tag
echo "Done"
fi
;;
h | ?)
echo "Options: -n skip download"
exit 0
;;
*)
echo "Unknown option: $opt"
exit 1
;;
esac
done
if [ "$SKIP_DOWNLOAD" = "0" ]; then ./download-midpoint; fi
docker build --tag tier/midpoint:latest .
if [ "$SKIP_DOWNLOAD" = "0" ]; then ./download-midpoint || exit 1; fi
docker build --tag $maintainer/$imagename:$tag --build-arg maintainer=$maintainer --build-arg imagename=$imagename . || exit 1
echo "---------------------------------------------------------------------------------------"
echo "The midPoint containers were successfully built. To start them, execute the following:"
echo ""
11 changes: 8 additions & 3 deletions download-midpoint
@@ -1,17 +1,22 @@
#!/bin/bash

DIR=`dirname "$0"`
source $DIR/common.bash
if [[ -n "$1" ]]; then
MP_VERSION=$1
else
MP_VERSION=3.9-SNAPSHOT
if [[ $tag == "latest" ]]; then
MP_VERSION=3.9-SNAPSHOT
else
MP_VERSION=$tag
fi
fi
echo "Downloading midPoint $MP_VERSION"
echo "-----------------------------------------"
curl --output $dir/midpoint-dist.tar.gz "https://evolveum.com/downloads/midpoint-tier/midpoint-$MP_VERSION-dist.tar.gz"
curl --output $DIR/midpoint-dist.tar.gz "https://evolveum.com/downloads/midpoint-tier/midpoint-$MP_VERSION-dist.tar.gz"
echo "-----------------------------------------"
echo "Checking the download..."
if tar -tf $dir/midpoint-dist.tar.gz >/dev/null; then
if tar -tf $DIR/midpoint-dist.tar.gz >/dev/null; then
echo "OK"
exit 0
else
22 changes: 0 additions & 22 deletions jenkins-rebuild.sh

This file was deleted.

4 changes: 2 additions & 2 deletions tests/main.bats
@@ -3,11 +3,11 @@
load ../common

@test "010 Image is present" {
docker image inspect tier/midpoint:latest
docker image inspect tier/midpoint:$tag
}

@test "020 Check basic components" {
docker run -i $maintainer/$imagename \
docker run -i $maintainer/$imagename:$tag \
find \
/usr/local/bin/startup.sh \
/opt/midpoint/var/ \

0 comments on commit 4947aa1

Please sign in to comment.