azure-pipelines code added

This commit is contained in:
sumedh
2024-11-06 12:06:35 +05:30
parent 2ac8bc1094
commit 988b2e14b0
2 changed files with 151 additions and 0 deletions

48
apollo-deployment.yaml Normal file
View File

@@ -0,0 +1,48 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: apollo
namespace: olympus
spec:
replicas: 1
selector:
matchLabels:
app: apollo
template:
metadata:
labels:
app: apollo
spec:
volumes:
- name: apollo-pv-storage
persistentVolumeClaim:
claimName: private-azurefile-pvc
containers:
- name: apollo
image: olytest/apollo:2ac8bc10
envFrom:
- configMapRef:
name: olympus-db-shared-cfg
env:
- name: DOCUMENT_UPLOAD_PATH
value: /mnt/apollo_storage/documents
- name: REPOSITORY_UPLOAD_PATH
value: /mnt/apollo_storage/repository
- name: GITLAB_CLOUD_TOKEN
value: glpat-z-72kM9b9yvqd8arvEX1
- name: GITLAB_ONPREMISES_TOKEN
value: VScokCa7anraKbXisnwe
- name: APOLLO_FE_URL
value: http://apollo-aks.olympusai.live
- name: EUREKA_URI
value: >-
http://eureka-server-service.olympus.svc.cluster.local:8761/eureka
resources: {}
volumeMounts:
- name: apollo-pv-storage
mountPath: /mnt/apollo_storage/documents
subPath: documents
- name: apollo-pv-storage
mountPath: /mnt/apollo_storage/repository
subPath: repository
imagePullPolicy: Always

103
azure-pipelines.yml Normal file
View File

@@ -0,0 +1,103 @@
# 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:
- develop
pool:
name: azureselfhosted
variables:
dockerRegistryServiceConnection: 'docker-registry-olympus'
imageName: 'apollo' # Replace with your Docker image name
shortCommitSha: '' # Initialize variable for short commit SHA
resources:
repositories:
- repository: olympus-common # Alias for the first repository
type: git
name: Olympus/olympus-common # Project and repository name
ref: master
steps:
- checkout: self # Check out the pipeline repository (optional)
- checkout: olympus-common # Check out the first repository
# Extract the short commit SHA
- script: |
echo "##vso[task.setvariable variable=shortCommitSha]$(echo $(Build.SourceVersion) | cut -c1-7)"
displayName: 'Set Short Commit SHA'
- script: |
echo "Building the first repository..."
ls -lrth
displayName: 'List olympus-common'
- task: Maven@3
inputs:
mavenPomFile: 'olympus-common/pom.xml'
goals: 'install'
# options: '-s $(mvnSettings.secureFilePath)'
#mavenAuthenticateFeed: true
#publishJUnitResults: true
#testResultsFiles: '**/TEST-*.xml'
#javaHomeOption: 'JDKVersion'
#jdkVersionOption: '1.21'
#mavenVersionOption: 'Default'
displayName: 'Build olympus-common'
- task: Maven@3
inputs:
mavenPomFile: 'apollo/pom.xml'
goals: 'install'
# options: '-s $(mvnSettings.secureFilePath)'
#mavenAuthenticateFeed: true
#publishJUnitResults: true
#testResultsFiles: '**/TEST-*.xml'
#javaHomeOption: 'JDKVersion'
#jdkVersionOption: '1.21'
#mavenVersionOption: 'Default'
displayName: 'Build apollo'
- script: |
echo "Listing the docker images..."
docker images
displayName: 'List docker images1'
- task: Docker@2
inputs:
command: 'buildAndPush'
containerRegistry: $(dockerRegistryServiceConnection)
repository: '$(imageName)'
tags: '$(shortCommitSha)'
Dockerfile: 'apollo/Dockerfile'
- script: |
echo "Listing the docker images..."
docker images
displayName: 'List docker images'
- script: |
echo "Updating imageName in dpeloyment.yaml"
echo "Before Substitution"
cat apollo/apollo-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)|" apollo/apollo-deployment.yaml
echo "After Substitution"
cat apollo/apollo-deployment.yaml
displayName: 'Update ImageName in YAML file'
- script: |
echo "deployment using kubectl"
kubectl apply -f apollo/apollo-deployment.yaml
displayName: 'deployment using kubectl'
- script: |
echo "remove the docker images..."
docker rmi $(docker images -q)
displayName: 'remove docker images'