001_CI.sh 1.4 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..."

据说甜蜜呢 committed
13 14
echo ""
echo "${appName} building..."
15
GetSolutionName solutionName
据说甜蜜呢 committed
16 17
dotnet build ${solutionName}	 

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

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

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
38
	echo "begin delivery for ${imagename}..."
据说甜蜜呢 committed
39 40 41 42 43
	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
44
	echo "delivery for ${imagename}:${version} has been successful."
据说甜蜜呢 committed
45 46
}

据说甜蜜呢 committed
47
GetServices services
据说甜蜜呢 committed
48 49
for service in ${services}
do
50
    GetServicePrefix ${service} servicePrefix
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."