I am new to Azure devops. as part of poc, i am trying to build a java based docker image.
so i have following pipeline yaml file
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/java
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
resources:
- repo: self
variables:
tag: '$(Build.BuildId)'
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
displayName: Build an image
inputs:
command: build
dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
tags: |
$(tag)
Expected
What i expected, this pipeline need to create a java application (jar file) and then it should create a docker image using this jar
Actual:
i am getting below error
unexpected value 'stages' azure pipelines
I didnt understand the issue...
Appreciated if anybody can help on this..?
Thanks
Please move this into job before your first task
- task: Docker@2
This is simply syntax issue. If you use steps you cant use stages on the root level. Here you may check syntax.
If you want to have jar creation as separate stage/job you have to define explicitly this as another stage or job. However in that way you need to publish and then download your jar as pipeline artifact.
If you stay with one single job you may just use: