Skip to content

Commit

Permalink
init for "Build MultiCloud Devops using Azure CI/CD Pipelines with Or…
Browse files Browse the repository at this point in the history
…acle Database Cloud Services" workshop
  • Loading branch information
paulparkinson committed Feb 29, 2024
1 parent c119c18 commit 4d8e243
Show file tree
Hide file tree
Showing 20 changed files with 115 additions and 6,015 deletions.
103 changes: 103 additions & 0 deletions azure-pipelines-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Deploy to Azure Kubernetes Service
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- main

resources:
- repo: self

variables:

# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'ba554595-2da8-4cf6-88c4-a57c75966491'
imageRepository: 'multicloudapp'
containerRegistry: 'multicloud.azurecr.io'
dockerfilePath: '**/Dockerfile'
tag: '$(Build.BuildId)'
imagePullSecret: 'multicloud2012b828-auth'

# Agent VM image name
vmImageName: 'ubuntu-latest'

# Name of the new namespace being created to deploy the PR changes.
k8sNamespaceForPR: 'review-app-$(System.PullRequest.PullRequestId)'

stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '17'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- task: Maven@4
inputs:
mavenPomFile: 'pom.xml'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
javaHomeOption: 'JDKVersion'
mavenVersionOption: '1.17'
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- upload: manifests
artifact: manifests



- stage: Deploy
displayName: Deploy stage
dependsOn: Build

jobs:

- deployment: Deploy
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
displayName: Deploy
pool:
vmImage: $(vmImageName)
environment: 'paulparkinsonazuredevopsoracledatabase-8684.default'
strategy:
runOnce:
deploy:
steps:
- task: KubernetesManifest@0
displayName: Create imagePullSecret
inputs:
action: createSecret
secretName: $(imagePullSecret)
dockerRegistryEndpoint: $(dockerRegistryServiceConnection)

- script: |
yq eval '.spec.template.spec.containers[0].env += [{"name": "AZURE_LOG_LEVEL", "value": "verbose"}, {"name": "AZURE_CLIENT_ID", "value": "$(AZURE_CLIENT_ID)"}, {"name": "AZURE_CLIENT_SECRET", "value": "$(AZURE_CLIENT_SECRET)"}, {"name": "AZURE_TENANT_ID", "value": "$(AZURE_TENANT_ID)"}]' -i $(Pipeline.Workspace)/manifests/deployment.yml
displayName: 'Add Environment Variable with yq'
- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
inputs:
action: deploy
manifests: |
$(Pipeline.Workspace)/manifests/deployment.yml
$(Pipeline.Workspace)/manifests/service.yml
imagePullSecrets: |
$(imagePullSecret)
containers: |
$(containerRegistry)/$(imageRepository):$(tag)
19 changes: 7 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@
<artifactId>spring-jdbc</artifactId>
<version>6.0.11</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring.boot.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
Expand All @@ -57,17 +63,6 @@
<artifactId>ojdbc-provider-azure</artifactId>
<version>1.0.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.oracle.database.jdbc</groupId>-->
<!-- <artifactId>ojdbc-provider-oci</artifactId>-->
<!-- <version>1.0.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring.boot.version}</version>
<scope>test</scope>
</dependency>

</dependencies>
<build>
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/oraclemulticloud/MultiCloudController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package oraclemulticloud;


import java.sql.*;

import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -21,12 +20,11 @@ public MultiCloudController(DataSource dataSource) {
jdbcTemplate = new JdbcTemplate(dataSource);
}

@CrossOrigin
@GetMapping("/teststring")
public String teststring() throws Exception {
return "teststring";
}
@CrossOrigin

@GetMapping("/test")
public String test() throws Exception {
String url = "jdbc:oracle:thin:@config-azure:multicloud-app-config?key=/multicloudapp/";
Expand All @@ -36,8 +34,9 @@ public String test() throws Exception {
Connection cn = ds.getConnection();
Statement st = cn.createStatement();
String returnString = cn + " ";
ResultSet rs = st.executeQuery("SELECT 'Hello, db' FROM sys.dual");
if (rs.next()) returnString+= "asdf" + rs.getString(1) + " : ";
// Replace with "SELECT 'Hello, db' FROM sys.dual" if cicd_test_table doesn't exist or any other applicable SQL
ResultSet rs = st.executeQuery("SELECT * FROM cicd_test_table");
if (rs.next()) returnString+= "value = " + rs.getString(1) + " : ";
return "got the conn :" + returnString;
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
spring:
datasource:
# Example where TNS_ADMIN is the location of the wallet
# url: "jdbc:oracle:thin:@testdb_high?TNS_ADMIN=/locationofwallet"
url: "jdbc:oracle:thin:@indadw_high?TNS_ADMIN=/Users/pparkins/Downloads/myhealthcarewallet"
url: "jdbc:oracle:thin:@testdb_high?TNS_ADMIN=/locationofwallet"
username: testuser
password: testpassword
driver-class-name: oracle.jdbc.OracleDriver
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/static/3dmodels.html

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
40 changes: 0 additions & 40 deletions src/main/resources/static/download.html

This file was deleted.

Binary file removed src/main/resources/static/images/Or-logo.jpg
Binary file not shown.
Loading

0 comments on commit 4d8e243

Please sign in to comment.