forked from shivaaws69/Wisdom-School-Spring-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
59 lines (51 loc) · 1.69 KB
/
azure-pipelines.yml
File metadata and controls
59 lines (51 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
trigger:
- master # Change this to your branch
pool:
name: sample # Self-hosted agent pool name
demands:
- Agent.Name -equals school # Ensuring the correct agent is used
variables:
ACR_NAME: "sampelschool" # Name of your Azure Container Registry
IMAGE_NAME: "school" # Name of the Docker image
IMAGE_TAG: "$(Build.BuildId)" # Unique tag for each build
MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository
stages:
- stage: Build
displayName: "Build Java and Docker Image"
jobs:
- job: BuildJob
displayName: "Build and Package App"
steps:
- task: Maven@3
displayName: "Run Maven Clean Package"
inputs:
mavenPomFile: "pom.xml"
goals: "clean package"
publishJUnitResults: true
options: "-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)"
javaHomeOption: "JDKVersion"
jdkVersionOption: "/usr/lib/jvm/java-8-openjdk-amd64"
mavenVersionOption: "Default"
mavenAuthenticateFeed: false
- script: |
echo "Building Docker Image..."
docker build -t $(ACR_NAME).azurecr.io/$(IMAGE_NAME):$(IMAGE_TAG) .
displayName: "Build Docker Image"
- stage: Push
displayName: "Push Docker Image to ACR"
jobs:
- job: PushJob
displayName: "Push Image to Azure Container Registry"
steps:
- task: AzureCLI@2
displayName: "Login to ACR"
inputs:
azureSubscription: "azurerm"
scriptType: "bash"
scriptLocation: "inlineScript"
inlineScript: |
az acr login --name $(ACR_NAME)
- script: |
echo "Pushing Docker image to ACR..."
docker push $(ACR_NAME).azurecr.io/$(IMAGE_NAME):$(IMAGE_TAG)
displayName: "Push Docker Image"