diff --git a/build/aro/openshift-app-build-template.yml b/build/aro/openshift-app-build-template.yml new file mode 100644 index 000000000..5ede960a5 --- /dev/null +++ b/build/aro/openshift-app-build-template.yml @@ -0,0 +1,44 @@ +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + name: ${TEMPLATE_NAME} +objects: +- apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + labels: + build: ${APPLICATION_NAME} + template: ${TEMPLATE_NAME} + name: ${APPLICATION_NAME} + spec: + failedBuildsHistoryLimit: 5 + nodeSelector: null + output: + to: + kind: ImageStreamTag + name: ${APPLICATION_NAME}:latest + postCommit: {} + resources: {} + runPolicy: Serial + source: + binary: {} + type: Binary + strategy: + sourceStrategy: + from: + kind: ImageStreamTag + name: dotnet:3.1 + namespace: openshift + type: Source + successfulBuildsHistoryLimit: 5 + triggers: [] +parameters: +- description: The name for the application. + displayName: Application Name + name: APPLICATION_NAME + required: true +- description: The template name. + displayName: Template Name + name: TEMPLATE_NAME + required: true + value: webapp-build-config-template \ No newline at end of file diff --git a/build/aro/webapp-container-build.yml b/build/aro/webapp-container-build.yml index a786ae543..0999f3e7b 100644 --- a/build/aro/webapp-container-build.yml +++ b/build/aro/webapp-container-build.yml @@ -16,32 +16,12 @@ jobs: - script: 'oc project $(OpenShiftProject)' failOnStderr: true displayName: 'Set Project Context' - - powershell: | - $pinfo = New-Object System.Diagnostics.ProcessStartInfo - $pinfo.FileName = "oc.exe" - $pinfo.RedirectStandardError = $true - $pinfo.RedirectStandardOutput = $true - $pinfo.UseShellExecute = $false - $pinfo.Arguments = "get buildConfig $(AppName)" - $p = New-Object System.Diagnostics.Process - $p.StartInfo = $pinfo - $p.Start() | Out-Null - $p.WaitForExit() - $stdout = $p.StandardOutput.ReadToEnd() - $stderr = $p.StandardError.ReadToEnd() - Write-Host "stdout: $stdout" - Write-Host "stderr: $stderr" - Write-Host "exit code: " + $p.ExitCode - $buildExists = $stdout.Contains("$(AppName)") - Write-Host "##vso[task.setvariable variable=BuildExists;]$buildExists" - displayName: 'Check for Existing Build' - task: DownloadPipelineArtifact@2 inputs: artifact: drop - - script: 'oc new-build --name=$(AppName) dotnet:3.1 --binary=true' + - script: 'oc process -f openshift-app-build-template.yml -p APPLICATION_NAME=$(AppName) | oc apply -f-' failOnStderr: true - displayName: 'Create OpenShift Build' - condition: and(succeeded(), eq(variables['BuildExists'], False)) + displayName: 'Ensure OpenShift BuildConfig' - powershell: | $pinfo = New-Object System.Diagnostics.ProcessStartInfo $pinfo.FileName = "oc.exe" diff --git a/deploy/api-app-template.yml b/deploy/aro/openshift-webapp-deploy-template.yml similarity index 90% rename from deploy/api-app-template.yml rename to deploy/aro/openshift-webapp-deploy-template.yml index 4b829c435..cfda9d09c 100644 --- a/deploy/api-app-template.yml +++ b/deploy/aro/openshift-webapp-deploy-template.yml @@ -1,13 +1,14 @@ apiVersion: template.openshift.io/v1 kind: Template metadata: - name: 'api-template' + name: ${TEMPLATE_NAME} objects: - apiVersion: apps.openshift.io/v1 kind: DeploymentConfig metadata: labels: app: ${APPLICATION_NAME} + template: ${TEMPLATE_NAME} name: ${APPLICATION_NAME} spec: replicas: 1 @@ -54,6 +55,7 @@ objects: metadata: labels: app: ${APPLICATION_NAME} + template: ${TEMPLATE_NAME} name: ${APPLICATION_NAME} spec: ports: @@ -77,3 +79,8 @@ parameters: displayName: Image Registry Project Name name: IMAGE_REGISTRY_PROJECT_NAME required: true +- description: The template name. + displayName: Template Name + name: TEMPLATE_NAME + required: true + value: webapp-template