Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit fb519b0

Browse files
dtzarrguthriemsft
authored andcommitted
Add switch to deploy from git branch (#301)
* Add gitbranch switch * Cleanup unused code * Git branch shakeout (#302)
1 parent a192fe7 commit fb519b0

File tree

4 files changed

+19
-50
lines changed

4 files changed

+19
-50
lines changed

provision-team/setup.sh

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ declare subscriptionId=""
1010
declare resourceGroupLocation=""
1111
declare teamName=""
1212
declare teamNumber=""
13-
declare azcliVerifiedVersion="2.0.43"
1413
declare azureUserName=""
1514
declare azurePassword=""
1615
declare recipientEmail=""
@@ -79,47 +78,6 @@ if [ ! $? == 0 ]; then
7978
exit 1
8079
fi
8180

82-
# Check if az is installed and that we can install it
83-
#type -p az
84-
#if [[ ! $? == 0 ]]; then
85-
# # is az is not present we need to install it
86-
# echo "The script need the az command line to be installed\n"
87-
# echo "https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest"
88-
# exit 1
89-
#else
90-
# currentCliVersion=$(echo "$(az --version)" | sed -ne 's/azure-cli (\(.*\))/\1/p' )
91-
# if [ $currentCliVersion != $azcliVersion ]; then
92-
# echo "Error current az cli version $currentCliVersion does not match expected version $azcliVerifiedVersion"
93-
# exit 1
94-
# fi
95-
#fi
96-
#
97-
##Prompt for parameters is some required parameters are missing
98-
#if [[ -z "$subscriptionId" ]]; then
99-
# echo "Your subscription ID can be looked up with the CLI using: az account show --out json "
100-
# echo "Enter your subscription ID:"
101-
# read subscriptionId
102-
# [[ "${subscriptionId:?}" ]]
103-
#fi
104-
#
105-
#if [[ -z "$resourceGroupLocation" ]]; then
106-
# echo "If creating a *new* resource group, you need to set a location "
107-
# echo "You can lookup locations with the CLI using: az account list-locations "
108-
#
109-
# echo "Enter resource group location:"
110-
# read resourceGroupLocation
111-
#fi
112-
#
113-
#if [[ -z "$teamName" ]]; then
114-
# echo "Enter a team name to be used in app provisioning:"
115-
# read teamName
116-
#fi
117-
#
118-
#if [ -z "$subscriptionId" ] || [ -z "$resourceGroupLocation" ] || [ -z "$teamName" ] ; then
119-
# echo "Parameter missing..."
120-
# usage
121-
#fi
122-
#
12381
randomChar() {
12482
s=abcdefghijklmnopqrstuvxwyz0123456789
12583
p=$(( $RANDOM % 36))

provision-vm/Docker/startup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ echo "ChatConnectionString= $CHATCONNECTIONSTRING"
1111
echo "ChatConnectionQueue= $CHATMESSAGEQUEUE"
1212
echo "Tenant is $TENANTID"
1313
echo "AppId is $APPID"
14+
echo "Git Branch is $GITBRANCH"
1415

1516
############### Pulling Openhack-tools from Github ###############
16-
git clone https://github.com/Azure-Samples/openhack-devops-proctor.git /home/azureuser/openhack-devops-proctor
17+
git clone -b $GITBRANCH https://github.com/Azure-Samples/openhack-devops-proctor.git /home/azureuser/openhack-devops-proctor
1718
# RUN chown azureuser:azureuser -R /home/azureuser/openhack-devops-proctor/.
1819

19-
##### TODO This line will be removed before the PR merged
2020
cd /home/azureuser/openhack-devops-proctor
2121
cd /home/azureuser
2222

provision-vm/azuredeploy.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@
7979
"16.04-LTS",
8080
"18.04-LTS"
8181
]
82+
},
83+
"gitBranch": {
84+
"type": "string",
85+
"defaultValue": "master",
86+
"metadata": {
87+
"description": "The git branch which will be used to provision the team environments from the devopsoh-proctor repository."
88+
}
8289
}
8390
},
8491
"variables": {
@@ -106,7 +113,9 @@
106113
"virtualNetworkName": "proctorVMVNET",
107114
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
108115
"sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]",
109-
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
116+
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
117+
"gitBranch": "[parameters('gitBranch')]",
118+
"gitUri": "[concat('https://raw.githubusercontent.com/Azure-Samples/openhack-devops-proctor/',variables('gitBranch'),'/provision-vm/proctorVMSetup.sh')]"
110119
},
111120
"resources": [
112121
{
@@ -239,9 +248,9 @@
239248
"autoUpgradeMinorVersion": true,
240249
"settings": {
241250
"fileUris": [
242-
"https://raw.githubusercontent.com/Azure-Samples/openhack-devops-proctor/master/provision-vm/proctorVMSetup.sh"
251+
"[variables('gitUri')]"
243252
],
244-
"commandToExecute": "[concat('sh proctorVMSetup.sh', ' ', variables('azureUserName'), ' ', variables('singleQuote'), variables('azurePassword'), variables('singleQuote'), ' ', subscription().subscriptionId, ' ', resourceGroup().location, ' ', variables('teamName'), ' ', variables('recipientEmail'), ' ', variables('singleQuote'), variables('ChatConnectionString'), variables('singleQuote'), ' ', variables('singleQuote'), variables('ChatMessageQueue'), variables('singleQuote'), ' ', variables('azureTenant'), ' ', variables('azureAppId') )]"
253+
"commandToExecute": "[concat('sh proctorVMSetup.sh', ' ', variables('azureUserName'), ' ', variables('singleQuote'), variables('azurePassword'), variables('singleQuote'), ' ', subscription().subscriptionId, ' ', resourceGroup().location, ' ', variables('teamName'), ' ', variables('recipientEmail'), ' ', variables('singleQuote'), variables('ChatConnectionString'), variables('singleQuote'), ' ', variables('singleQuote'), variables('ChatMessageQueue'), variables('singleQuote'), ' ', variables('azureTenant'), ' ', variables('azureAppId'), ' ', variables('gitBranch') )]"
245254
}
246255
}
247256
}

provision-vm/proctorVMSetup.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CHATCONNECTIONSTRING=$7
1414
CHATMESSAGEQUEUE=$8
1515
TENANTID=$9
1616
APPID=${10}
17-
#GITBRANCH=
17+
GITBRANCH=${11}
1818

1919
echo "############### Adding package respositories ###############"
2020
# Get the Docker GPG key
@@ -34,7 +34,7 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-commo
3434
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker-ce docker-ce-cli containerd.io
3535

3636
#Add user to docker usergroup
37-
sudo DEBIAN_FRONTEND=noninteractive apt-get remove -y unscd
37+
sudo DEBIAN_FRONTEND=noninteractive apt-get remove -y unscd
3838
sudo usermod -aG docker azureuser
3939

4040
#Holding walinuxagent before upgrade
@@ -52,6 +52,7 @@ echo "ChatConnectionString= $CHATCONNECTIONSTRING"
5252
echo "ChatConnectionQueue= $CHATMESSAGEQUEUE"
5353
echo "Tenant is $TENANTID"
5454
echo "AppId is $APPID"
55+
echo "Git Branch is $GITBRANCH"
5556

5657
# Launching the team provisioning in background
5758

@@ -65,6 +66,7 @@ export CHATCONNECTIONSTRING=$CHATCONNECTIONSTRING
6566
export CHATMESSAGEQUEUE=$CHATMESSAGEQUEUE
6667
export TENANTID=$TENANTID
6768
export APPID=$APPID
69+
export GITBRANCH=$GITBRANCH
6870

6971
# nginx directory creation
7072
mkdir -p /home/nginx/config
@@ -74,5 +76,5 @@ mkdir -p /home/nginx/contents
7476
mkdir -p /home/azureuser/logs
7577

7678
# /bin/bash -c 'docker run -d --name docker-daemon --privileged docker:stable-dind &'
77-
/bin/bash -c 'docker run --mount '"'"'type=bind,src=/home/nginx/config,dst=/home/nginx/config'"'"' --mount '"'"'type=bind,src=/home/nginx/contents,dst=/home/nginx/contents'"'"' --mount '"'"'type=bind,src=/home/azureuser/logs,dst=/home/azureuser/logs'"'"' -v /var/run/docker.sock:/var/run/docker.sock -d -e AZUREUSERNAME -e AZUREPASSWORD -e SUBID -e LOCATION -e TEAMNAME -e RECIPIENTEMAIL -e CHATCONNECTIONSTRING -e CHATMESSAGEQUEUE -e TENANTID -e APPID devopsoh/proctor-container &'
79+
/bin/bash -c 'docker run -v '"'"'type=bind,src=/home/nginx/config,dst=/home/nginx/config'"'"' --mount '"'"'type=bind,src=/home/nginx/contents,dst=/home/nginx/contents'"'"' --mount '"'"'type=bind,src=/home/azureuser/logs,dst=/home/azureuser/logs'"'"' -v /var/run/docker.sock:/var/run/docker.sock -d -e AZUREUSERNAME -e AZUREPASSWORD -e SUBID -e LOCATION -e TEAMNAME -e RECIPIENTEMAIL -e CHATCONNECTIONSTRING -e CHATMESSAGEQUEUE -e TENANTID -e APPID -e GITBRANCH devopsoh/proctor-container &'
7880
#echo "############### End of custom script ###############"

0 commit comments

Comments
 (0)