0

I have a Springboot project and I'm trying to deploy it to the Azure web app via Jenkins job. Created maven project in Jenkins for compiling, testing, and deploying the projects are in the below name.

  1. CheckoutandBuild project - here I configured my bitbucket which has my source code. this job just fetches the source code and executes the maven command clean compile Note: due to security I don't commit my application.properties to the bitbucket branch.
  2. UnitTest project - based on the stable build of the CheckoutandBuild project, this job will execute the maven command test. I'm getting the below error while executing this project
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.

Then how can I configure the properties file in Jenkins to make the build successful? I tried adding the app.properties in Manage Jenkins->Managed files of Jenkins, But it is not taking my properties file.

How to add and configure my app.properties in the Jenkins job? is there any other way to add my properties?

Saeed Zhiany
  • 2,051
  • 9
  • 30
  • 41
jayanthi
  • 11
  • 1
  • Does this answer your question? [Using a Jenkins variable in application properties file of spring boot app](https://stackoverflow.com/questions/58880497/using-a-jenkins-variable-in-application-properties-file-of-spring-boot-app) – Ecstasy May 10 '22 at 12:37
  • Thanks for reply DeepDave. Actually we commit spring boot proj to bitbucket except app.prop. I want to configure this app.prop in my jenkins job separately. because my job while executing maven test command throwing an error "Could not resolve placeholder 'azure.config.url' in value "${azure.config.url}"". azure.config.url value available in app.prop file.In eclipse it is working because i have app.prop in src/main/resources. – jayanthi May 10 '22 at 13:10

2 Answers2

0

You should be able to copy your managed files to your build in Jenkins like this plugin suggests.

By IMO you should reconsider your approach, the property file is an integrated part of the project. 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}

See more details here

hillel_guy
  • 646
  • 6
  • 17
0

You can pass your property while executing mvn command on Jenkins, considering you are using mvnw / 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.

Ashish Patil
  • 4,428
  • 1
  • 15
  • 36