001_CI.sh 1.42 KB
Newer Older
据说甜蜜呢 committed
1 2 3 4 5
#!/bin/bash

set -e

# Import external functions
据说甜蜜呢 committed
6
chmod +x ./devops/PipeLines/Functions.sh
据说甜蜜呢 committed
7
source ./devops/PipeLines/Functions.sh
据说甜蜜呢 committed
8 9

GetAppName appName
据说甜蜜呢 committed
10
echo ""
据说甜蜜呢 committed
11 12
echo "Continuous integration for ${appName} starting..."

13
GetSolutionName solutionName
据说甜蜜呢 committed
14 15
dotnet build ${solutionName}	 

据说甜蜜呢 committed
16
echo ""
据说甜蜜呢 committed
17 18
echo "Please check the version of each microservice carefully !!!"

19
GetVersion version
据说甜蜜呢 committed
20
GetImageUserName registryUserName
据说甜蜜呢 committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

declare publishOutputDir=./publish

rm -fr ${publishOutputDir}
mkdir -p ${publishOutputDir}

function CI()
{
	declare publishable=$1
	declare imagename=$2

	echo ""
	declare imagefullname=${RegistryHost}/${registryUserName}/${imagename}:${version}
	declare publishFile=$3

据说甜蜜呢 committed
36
	echo "begin delivery for ${imagename}..."
据说甜蜜呢 committed
37 38 39 40 41
	mkdir -p ${publishOutputDir}/${imagename}
	dotnet publish ${publishFile} -o ../../publish/${imagename} -c release --no-restore  
	docker build -t ${imagefullname} ${publishOutputDir}/${imagename}
	docker push ${imagefullname}
	rm -fr ${publishOutputDir}/${imagename}
据说甜蜜呢 committed
42
	echo "delivery for ${imagename}:${version} has been successful."
据说甜蜜呢 committed
43 44
}

据说甜蜜呢 committed
45
GetServices services
据说甜蜜呢 committed
46 47 48 49 50
declare servicePrefix=""
declare serviceName=""
for service in ${services}
do
	servicePrefix=($(echo ${service} | awk '{print $9}')) 
51
	IsPublishableOf ${servicePrefix} isPublishable
据说甜蜜呢 committed
52 53 54 55 56 57
	GetServiceName "${servicePrefix}" serviceName
	CI "${servicePrefix}" "./src/${servicePrefix}/${serviceName}.csproj"
done

echo ""
echo "Continuous integration for ${appName} has been successful."