[英]How to configure the application.properties externally in the Jenkins maven job?
I have a Springboot project and I'm trying to deploy it to the Azure web app via Jenkins job.我有一个 Springboot 项目,我正在尝试通过 Jenkins 作业将其部署到 Azure Web 应用程序。 Created maven project in Jenkins for compiling, testing, and deploying the projects are in the below name.在 Jenkins 中创建的用于编译、测试和部署项目的 maven 项目名称如下。
application.properties
to the bitbucket branch.这项工作只是获取源代码并执行 maven 命令clean compile注意:由于安全性,我不会将application.properties
提交到 bitbucket 分支。Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'azureADUtils': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'azure.openid.config.url' in value "${azure.openid.config.url}"
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'azure.config.url' in value "${azure.config.url}".
It is clearly saying it is expecting the value ${azure.config.url}
which is available in my app.properties
which I haven't committed in bitbucket.很明显,它期望值${azure.config.url}
在我的app.properties
中可用,而我没有在 bitbucket 中提交。
Then how can I configure the properties file in Jenkins to make the build successful?那么如何在 Jenkins 中配置属性文件以使构建成功呢? I tried adding the app.properties
in Manage Jenkins->Managed files of Jenkins, But it is not taking my properties file.我尝试在Manage Jenkins->Managed files of Jenkins 中添加app.properties
,但它没有占用我的属性文件。
How to add and configure my app.properties
in the Jenkins job?如何在 Jenkins 作业中添加和配置我的app.properties
? is there any other way to add my properties?还有其他方法可以添加我的属性吗?
You should be able to copy your managed files to your build in Jenkins like this plugin suggests.您应该能够像这个插件建议的那样将您的托管文件复制到您在 Jenkins 中的构建。
By IMO you should reconsider your approach, the property file is an integrated part of the project.通过 IMO,您应该重新考虑您的方法,属性文件是项目的一个组成部分。 Does your entire property file is sensitive?您的整个属性文件是否敏感? Perhaps you could just leave the sensitive values with an environment variable placeholder, like this:也许您可以将敏感值保留为环境变量占位符,如下所示:
non-sensitive-property=value1234
sensitive-property=${MY_ENV_VAR}
You can pass your property while executing mvn command on Jenkins, considering you are using mvnw / mvn:考虑到您使用的是 mvnw / mvn,您可以在 Jenkins 上执行 mvn 命令时传递您的属性:
./mvnw spring-boot:run \
-Dspring-boot.run.arguments="--azure.config.url=https://url"
Or或者
./mvnw spring-boot:run -Dspring-boot.run.jvmArguments="\
-Dazure.config.url=https://url"
Hopefully this is what you are looking for.希望这是您正在寻找的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.