Azure DevOps Build Pipeline - Build Spring Boot based on specific application.profile
Azure DevOps Build Pipeline - Build Spring Boot based on specific application.profile
我有一个 Spring 引导应用程序,我利用 Azure DevOps 自动 build/test 项目并部署工件。
我的问题如下:如何根据特定的 application.profile 进行构建?现在它刚刚构建,但在我的项目中我有以下 3 个文件:
- application.properties
- 应用-test.properties
- 应用-acceptance.properties
例如,我如何基于 "application-test.properties" 构建?
目前我的代码如下所示:
stages:
- stage: Build
displayName: Build stage
jobs:
- job: MavenPackageAndPublishArtifacts
displayName: Maven Package and Publish Artifacts
pool:vmImage: $(vmImageName)
steps:
- task: Maven@3
displayName: 'Maven Package'
inputs:
mavenPomFile: 'pom.xml'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
- task: CopyFiles@2
displayName: 'Copy Files to artifact staging directory'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)'
Contents: '**/target/*.?(war|jar)'
TargetFolder: $(Build.ArtifactStagingDirectory)
- upload: $(Build.ArtifactStagingDirectory)
artifact: drop
根据
Setting the SPRING_PROFILES_ACTIVE
environment variable will
activate the intended profile. for example, in order to activate the
qa
profile, set the SPRING_PROFILES_ACTIVE
environment variable to
qa
. Read more about profile specific properties here in Spring
Boot Documentation.
关于如何使用环境,你也可以看看这个博客:Using Environment Variables in Azure DevOps Pipelines
我有一个 Spring 引导应用程序,我利用 Azure DevOps 自动 build/test 项目并部署工件。
我的问题如下:如何根据特定的 application.profile 进行构建?现在它刚刚构建,但在我的项目中我有以下 3 个文件:
- application.properties
- 应用-test.properties
- 应用-acceptance.properties
例如,我如何基于 "application-test.properties" 构建?
目前我的代码如下所示:
stages:
- stage: Build
displayName: Build stage
jobs:
- job: MavenPackageAndPublishArtifacts
displayName: Maven Package and Publish Artifacts
pool:vmImage: $(vmImageName)
steps:
- task: Maven@3
displayName: 'Maven Package'
inputs:
mavenPomFile: 'pom.xml'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
- task: CopyFiles@2
displayName: 'Copy Files to artifact staging directory'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)'
Contents: '**/target/*.?(war|jar)'
TargetFolder: $(Build.ArtifactStagingDirectory)
- upload: $(Build.ArtifactStagingDirectory)
artifact: drop
根据
Setting the
SPRING_PROFILES_ACTIVE
environment variable will activate the intended profile. for example, in order to activate theqa
profile, set theSPRING_PROFILES_ACTIVE
environment variable toqa
. Read more about profile specific properties here in Spring Boot Documentation.
关于如何使用环境,你也可以看看这个博客:Using Environment Variables in Azure DevOps Pipelines