Skip to content
Permalink
Browse files

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.
  • Loading branch information
mederly committed Oct 5, 2018
1 parent 3b8dcd8 commit 4947aa151e267b42b037be99f65d9a6c8c13c29f
Showing with 41 additions and 42 deletions.
  1. +1 −1 Dockerfile
  2. +5 −8 Jenkinsfile
  3. +25 −6 build.sh
  4. +8 −3 download-midpoint
  5. +0 −22 jenkins-rebuild.sh
  6. +2 −2 tests/main.bats
@@ -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
@@ -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}"
@@ -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 ""
@@ -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

This file was deleted.

@@ -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.
You can’t perform that action at this time.