Create a java project and compile with Azure pipeline

STEP 1. Create a java project with maven

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false

STEP 2. Upload created my-app to GIT or Azure repo

STEP 3. Create my-app.yml as pipeline

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more: this is dummy commit
# https://aka.ms/yaml

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- script: |
    echo Add other tasks to build, test, and deploy your project.
    echo See https://aka.ms/yaml
  displayName: 'Run a multi-line script'

- task: Maven@3
  inputs:
    mavenPomFile: 'my-app/pom.xml' 

- publish: $(System.DefaultWorkingDirectory)
  artifact: 'my-app-1.0-SNAPSHOT.jar'


- task: DownloadPipelineArtifact@2
  inputs:
    buildType: current
    artifact: 'my-app-1.0-SNAPSHOT.jar'


STEP 4. Run the pipeline and check the my-app-1.0-SNAPSHOT.jar

Leave a Reply

Your email address will not be published. Required fields are marked *