This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add combined Jenkins & Spinnaker template
- Loading branch information
Showing
4 changed files
with
194 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
#!/bin/bash | ||
|
||
function print_usage() { | ||
cat <<EOF | ||
https://github.com/Azure/azure-quickstart-templates/tree/master/301-jenkins-acr-spinnaker-k8s | ||
Command | ||
$0 | ||
Arguments | ||
--client_id|-ci [Required] : Service principal client id used to dynamically manage resource in your subscription | ||
--client_key|-ck [Required] : Service principal client key used to dynamically manage resource in your subscription | ||
--subscription_id|-si [Required] : Subscription Id | ||
--tenant_id|-ti [Required] : Tenant Id | ||
--user_name|-un [Required] : Admin user name for your Spinnaker VM and Kubernetes cluster | ||
--git_repository|-gr [Required] : Git URL with a Dockerfile in it's root | ||
--resource_group|-rg [Required] : Resource group containing your Kubernetes cluster | ||
--master_fqdn|-mf [Required] : Master FQDN of your Kubernetes cluster | ||
--master_count|-mc [Required] : Master count of your Kubernetes cluster | ||
--storage_account_name|-san [Required] : Storage Account name used for Spinnaker's persistent storage | ||
--storage_account_key|-sak [Required] : Storage Account key used for Spinnaker's persistent storage | ||
--azure_container_registry|-acr [Required] : Azure Container Registry url | ||
--docker_repository|-dr : Name of the docker repository to be created in your ACR | ||
--pipeline_port|-pp : Port to target in your pipeline | ||
--artifacts_location|-al : Url used to reference other scripts/artifacts. | ||
--sas_token|-st : A sas token needed if the artifacts location is private. | ||
EOF | ||
} | ||
|
||
function throw_if_empty() { | ||
local name="$1" | ||
local value="$2" | ||
if [ -z "$value" ]; then | ||
echo "Parameter '$name' cannot be empty." 1>&2 | ||
print_usage | ||
exit -1 | ||
fi | ||
} | ||
|
||
#Set defaults | ||
pipeline_port="8000" | ||
artifacts_location="https://raw.githubusercontent.com/Azure/azure-devops-utils/master/" | ||
docker_repository="${vm_user_name}/myfirstapp" | ||
|
||
while [[ $# > 0 ]] | ||
do | ||
key="$1" | ||
shift | ||
case $key in | ||
--client_id|-ci) | ||
client_id="$1" | ||
shift | ||
;; | ||
--client_key|-ck) | ||
client_key="$1" | ||
shift | ||
;; | ||
--subscription_id|-si) | ||
subscription_id="$1" | ||
shift | ||
;; | ||
--tenant_id|-ti) | ||
tenant_id="$1" | ||
shift | ||
;; | ||
--user_name|-un) | ||
user_name="$1" | ||
shift | ||
;; | ||
--git_repository|-gr) | ||
git_repository="$1" | ||
shift | ||
;; | ||
--resource_group|-rg) | ||
resource_group="$1" | ||
shift | ||
;; | ||
--master_fqdn|-mf) | ||
master_fqdn="$1" | ||
shift | ||
;; | ||
--master_count|-mc) | ||
master_count="$1" | ||
shift | ||
;; | ||
--storage_account_name|-san) | ||
storage_account_name="$1" | ||
shift | ||
;; | ||
--storage_account_key|-sak) | ||
storage_account_key="$1" | ||
shift | ||
;; | ||
--azure_container_registry|-acr) | ||
azure_container_registry="$1" | ||
shift | ||
;; | ||
--docker_repository|-dr) | ||
docker_repository="$1" | ||
shift | ||
;; | ||
--pipeline_port|-pp) | ||
pipeline_port="$1" | ||
shift | ||
;; | ||
--artifacts_location|-al) | ||
artifacts_location="$1" | ||
shift | ||
;; | ||
--sas_token|-st) | ||
artifacts_location_sas_token="$1" | ||
shift | ||
;; | ||
--help|-help|-h) | ||
print_usage | ||
exit 13 | ||
;; | ||
*) | ||
echo "ERROR: Unknown argument '$key' to script '$0'" 1>&2 | ||
exit -1 | ||
esac | ||
done | ||
|
||
throw_if_empty --client_id $client_id | ||
throw_if_empty --client_key $client_key | ||
throw_if_empty --subscription_id $subscription_id | ||
throw_if_empty --tenant_id $tenant_id | ||
throw_if_empty --user_name $user_name | ||
throw_if_empty --git_repository $git_repository | ||
throw_if_empty --resource_group $resource_group | ||
throw_if_empty --master_fqdn $master_fqdn | ||
throw_if_empty --master_count $master_count | ||
throw_if_empty --storage_account_name $storage_account_name | ||
throw_if_empty --storage_account_key $storage_account_key | ||
throw_if_empty --azure_container_registry $azure_container_registry | ||
throw_if_empty --docker_repository $docker_repository | ||
throw_if_empty --pipeline_port $pipeline_port | ||
|
||
include_docker_build_pipeline="1" | ||
include_kubernetes_pipeline="1" | ||
pipeline_registry="$azure_container_registry" | ||
front50_port="8081" | ||
|
||
# Configure Spinnaker (do this first because the default InstallSpinnaker.sh script sets up front50 on port 8080 and that might fail if we did Jenkins first) | ||
curl --silent "${artifacts_location}quickstart_template/spinnaker_vm_to_kubernetes.sh${artifacts_location_sas_token}" | sudo bash -s -- -ci "$client_id" -ck "$client_key" -si "$subscription_id" -ti "$tenant_id" -un "$user_name" -rg "$resource_group" -mf "$master_fqdn" -mc "$master_count" -san "$storage_account_name" -sak "$storage_account_key" -acr "$azure_container_registry" -ikp "$include_kubernetes_pipeline" -prg "$pipeline_registry" -prp "$docker_repository" -pp "$pipeline_port" -fp "$front50_port" -al "$artifacts_location" -st "$artifacts_location_sas_token" | ||
|
||
# Configure Jenkins | ||
curl --silent "${artifacts_location}quickstart_template/201-jenkins-to-azure-container-registry.sh${artifacts_location_sas_token}" | sudo bash -s -- -i "$include_docker_build_pipeline" -u "$user_name" -g "$git_repository" -r "https://$azure_container_registry" -ru "$client_id" -rp "$client_key" -rr "$docker_repository" -al "$artifacts_location" -st "$artifacts_location_sas_token" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters