From d8731181f19f470107311206c4302a247d9324a4 Mon Sep 17 00:00:00 2001 From: "shamrao shinde, sumedh" Date: Thu, 7 Nov 2024 13:07:27 +0000 Subject: [PATCH] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 70 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..b914b59 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,70 @@ +# Build your Java project and run tests with Apache Maven. +# Add steps that analyze code, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/java +trigger: +- master +pool: + name: azureselfhosted +variables: + dockerRegistryServiceConnection: 'docker-registry-olympus' + imageName: 'hermione-fe' # Replace with your Docker image name + shortCommitSha: '' # Initialize variable for short commit SHA +steps: +- checkout: self # Check out the pipeline repository (optional) + +# Extract the short commit SHA +- script: | + echo "##vso[task.setvariable variable=shortCommitSha]$(echo $(Build.SourceVersion) | cut -c1-8)" + displayName: 'Set Short Commit SHA' +- script: | + echo "Building the first repository..." + ls -lrth + displayName: 'List hermione-fe directory' + +- script: | + echo "Listing the docker images..." + docker images + displayName: 'List docker images1' + +- task: Docker@2 + displayName: Build + inputs: + command: build + containerRegistry: $(dockerRegistryServiceConnection) + repository: '$(imageName)' + tags: '$(shortCommitSha)' + Dockerfile: 'Dockerfile' + arguments: '--build-arg VITE_BACKEND_URL=http://olympus-api-gateway-aks.olympusai.live/hermione' + +- task: Docker@2 + displayName: Push + inputs: + command: push + containerRegistry: $(dockerRegistryServiceConnection) + repository: '$(imageName)' + tags: '$(shortCommitSha)' + +- script: | + echo "Listing the docker images..." + docker images + displayName: 'List docker images' +- script: | + echo "Updating imageName in dpeloyment.yaml" + echo "Before Substitution" + cat hermione-fe-deployment.yaml + echo "###############################################" + echo "current shell: $SHELL" + echo "imagename bracket : $(imageName)" + echo "###############################################" + sed -i "s|image: olympusreg.azurecr.io/$(imageName):.*|image: olympusreg.azurecr.io/$(imageName):$(shortCommitSha)|" hermione-fe-deployment.yaml + echo "After Substitution" + cat hermione-fe-deployment.yaml + displayName: 'Update ImageName in YAML file' +- script: | + echo "deployment using kubectl" + kubectl apply -f hermione-fe-deployment.yaml + displayName: 'deployment using kubectl' +- script: | + echo "remove the docker images..." + docker rmi $(docker images -q) + displayName: 'remove docker images' \ No newline at end of file