Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added .pipelines for azure pipelines #26

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG DOCKER_BASE_IMAGE="ubuntu:latest"
FROM ${DOCKER_BASE_IMAGE}

RUN apt update


ENTRYPOINT ["tail", "-f", "/dev/null"]

15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Spring Framework Petclinic",
"build": {
"dockerfile": "Dockerfile",
"context": ".",
"args": {
"USERNAME": "${localEnv:USER}"
}
},
"containerEnv": {
"USER": "${localEnv:USER}"
}


}
36 changes: 36 additions & 0 deletions .pipelines/lib/app/jobs/build/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
parameters:
- name: APP
type: object

- name: PUBLISH
type: boolean
default: True
steps:

- ${{ if ne(parameters.APP.build.setup_env, 'none') }}:
- template: ${{ parameters.APP.build.setup_env }}

- task: Maven@3
inputs:
mavenPomFile: 'simple-java-project/pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
mavenAuthenticateFeed: true
publishJUnitResults: false
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'deploy'

- task: CopyFiles@2
displayName: Copy Artifacts from local to staging
inputs:
SourceFolder: $(Build.Repository.LocalPath)/target
Contents: '*.war'
TargetFolder: $(Build.ArtifactStagingDirectory)/${{ parameters.APP.name }}

- ${{ if eq(parameters.PUBLISH, 'True') }}:
- publish: '$(Build.ArtifactStagingDirectory)/${{ parameters.APP.name }}'
artifact: BUILD_${{ parameters.APP.name }}
displayName: Publish Artifacts ${{ parameters.APP.name }}

22 changes: 22 additions & 0 deletions .pipelines/lib/app/stages/build/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
parameters:
- name: APP
type: object
stages:
- stage: build_${{ parameters.APP.name }}
displayName: BuildJavaApp
jobs:
- job: build_${{ parameters.APP.name }}
pool:
name: $[ variables.${{ parameters.APP.build.pool }}]
workspace:
clean: all
container: default_image
condition: eq(${{ parameters.APP.build.enabled }}, 'true')
steps:
- checkout: self
clean: true
submodules: recursive
#path: $(code_repo_name)
- template: ../../jobs/build/build.yml
parameters:
APP: ${{ parameters.APP }}
6 changes: 6 additions & 0 deletions .pipelines/lib/custom/jobs/build/setup_build_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
steps:
- bash: |
cd /scripts
chmod +x script.sh
./script.sh
displayName: Setup env for Maven
42 changes: 42 additions & 0 deletions .pipelines/production/pr_develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Maven
# 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: none
pr:
branches:
include:
- main
parameters:
- name: DOCKER_BUILD_IMAGE
displayName: Docker image
type: string
default: 'gnishanth777/spring:1.8.0'
- name: JAVA_APP
displayName: JavaApp
type: object
default:
- name: javaApp
build:
enabled: true
setup_env: ../../custom/jobs/build/setup_build_env.yml
docker_image: default_image
pool: default_pool


resources:
containers:
- container: default_image
image: ${{ parameters.DOCKER_BUILD_IMAGE }}
variables:
- name: default_pool
value: 'Azure Pipelines'
stages:
- ${{ each app in parameters.JAVA_APP }}:
- template: ../lib/app/stages/build/build.yml
parameters:
APP: ${{ app }}



3 changes: 3 additions & 0 deletions .pipelines/vars/global_variables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variables:
code_repo_name: simple-java-project

12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
<artifactId>works-with-heroku</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<distributionManagement>
<repository>
<id>artifacts</id>
<url>https://pkgs.dev.azure.com/udz1kor/azurepipelinestest/_packaging/artifacts/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
Expand Down