manifests pipeline updated
This commit is contained in:
@@ -1,70 +1,110 @@
|
|||||||
# 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:
|
trigger:
|
||||||
- master
|
- master
|
||||||
pool:
|
|
||||||
name: azureselfhosted
|
|
||||||
variables:
|
variables:
|
||||||
dockerRegistryServiceConnection: 'docker-registry-olympus'
|
dockerRegistryServiceConnection: 'docker-registry-olympus'
|
||||||
imageName: 'hermione-fe' # Replace with your Docker image name
|
imageName: 'ariadne-fe' # Replace with your Docker image name
|
||||||
shortCommitSha: '' # Initialize variable for short commit SHA
|
shortCommitSha: '' # Initialize variable for short commit SHA
|
||||||
steps:
|
envName: 'aks-olympus'
|
||||||
- checkout: self # Check out the pipeline repository (optional)
|
azurecontainerRegistry: 'olympusreg.azurecr.io'
|
||||||
|
resourceName: 'olympus'
|
||||||
|
VITE_BACKEND_URL: 'http://olympus-api-gateway-aks.olympusai.live/hermione'
|
||||||
|
|
||||||
# Extract the short commit SHA
|
stages:
|
||||||
- script: |
|
- stage: Build
|
||||||
echo "##vso[task.setvariable variable=shortCommitSha]$(echo $(Build.SourceVersion) | cut -c1-8)"
|
displayName: Build stage
|
||||||
displayName: 'Set Short Commit SHA'
|
jobs:
|
||||||
- script: |
|
- job: Build
|
||||||
echo "Building the first repository..."
|
displayName: "Build & push to ACR"
|
||||||
ls -lrth
|
pool:
|
||||||
displayName: 'List hermione-fe directory'
|
name: azureselfhosted
|
||||||
|
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: |
|
- script: |
|
||||||
echo "Listing the docker images..."
|
echo "Building the first repository..."
|
||||||
docker images
|
ls -lrth
|
||||||
displayName: 'List docker images1'
|
displayName: 'list files'
|
||||||
|
|
||||||
|
- script: |
|
||||||
|
echo "Listing the docker images..."
|
||||||
|
docker images
|
||||||
|
displayName: 'List docker images'
|
||||||
|
|
||||||
- task: Docker@2
|
- task: Docker@2
|
||||||
displayName: Build
|
inputs:
|
||||||
inputs:
|
command: build
|
||||||
command: build
|
repository: '$(imageName)'
|
||||||
containerRegistry: $(dockerRegistryServiceConnection)
|
Dockerfile: 'Dockerfile'
|
||||||
repository: '$(imageName)'
|
containerRegistry: $(dockerRegistryServiceConnection)
|
||||||
tags: '$(shortCommitSha)'
|
tags: '$(shortCommitSha)'
|
||||||
Dockerfile: 'Dockerfile'
|
arguments: '--build-arg VITE_BACKEND_URL=$(VITE_BACKEND_URL)'
|
||||||
arguments: '--build-arg VITE_BACKEND_URL=http://olympus-api-gateway-aks.olympusai.live/hermione'
|
displayName: 'Build an image for container registry'
|
||||||
|
|
||||||
|
- task: Docker@2
|
||||||
|
inputs:
|
||||||
|
command: push
|
||||||
|
containerRegistry: $(dockerRegistryServiceConnection)
|
||||||
|
repository: '$(imageName)'
|
||||||
|
tags: '$(shortCommitSha)'
|
||||||
|
displayName: 'push an image to container registry'
|
||||||
|
|
||||||
|
- script: |
|
||||||
|
echo "Listing the docker images..."
|
||||||
|
docker images
|
||||||
|
displayName: 'List docker images'
|
||||||
|
|
||||||
|
- script: |
|
||||||
|
echo "Removing Docker images to clean up..."
|
||||||
|
docker rmi $(docker images -q)
|
||||||
|
displayName: 'Clean up Docker Images'
|
||||||
|
continueOnError: true
|
||||||
|
condition: always()
|
||||||
|
|
||||||
|
- script: |
|
||||||
|
echo "Listing the docker images..."
|
||||||
|
docker images
|
||||||
|
displayName: 'List docker images after removal'
|
||||||
|
|
||||||
|
- upload: manifests
|
||||||
|
artifact: manifests
|
||||||
|
|
||||||
|
- stage: Deploy
|
||||||
|
displayName: Deploy stage
|
||||||
|
dependsOn: Build
|
||||||
|
|
||||||
- task: Docker@2
|
jobs:
|
||||||
displayName: Push
|
- deployment: Deploy
|
||||||
inputs:
|
condition: succeeded()
|
||||||
command: push
|
displayName: "Deploy to ${{variables.envName}} environment"
|
||||||
containerRegistry: $(dockerRegistryServiceConnection)
|
pool:
|
||||||
repository: '$(imageName)'
|
name: azureselfhosted
|
||||||
tags: '$(shortCommitSha)'
|
environment:
|
||||||
|
name: $(envName).$(resourceName)
|
||||||
|
resourceType: Kubernetes
|
||||||
|
strategy:
|
||||||
|
runOnce:
|
||||||
|
deploy:
|
||||||
|
steps:
|
||||||
|
- script: |
|
||||||
|
echo "##vso[task.setvariable variable=shortCommitSha]$(echo $(Build.SourceVersion) | cut -c1-8)"
|
||||||
|
displayName: 'Set Short Commit SHA'
|
||||||
|
|
||||||
|
- script: |
|
||||||
|
echo "########################################################################"
|
||||||
|
echo "Short Commit SHA: $(shortCommitSha)"
|
||||||
|
displayName: 'Echo short commit SHA'
|
||||||
|
|
||||||
- script: |
|
- task: KubernetesManifest@0
|
||||||
echo "Listing the docker images..."
|
displayName: Deploy to Kubernetes cluster
|
||||||
docker images
|
inputs:
|
||||||
displayName: 'List docker images'
|
action: deploy
|
||||||
- script: |
|
manifests: |
|
||||||
echo "Updating imageName in dpeloyment.yaml"
|
$(Pipeline.Workspace)/manifests/hermione-fe-deployment.yaml
|
||||||
echo "Before Substitution"
|
containers: |
|
||||||
cat hermione-fe-deployment.yaml
|
$(azurecontainerRegistry)/$(imageName):$(shortCommitSha)
|
||||||
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'
|
|
||||||
Reference in New Issue
Block a user