Skip to content

How to pass Spring profile to Spring Boot application run by Jenkins Job?

I need to run a Spring Boot app using different configuration files. In local I can do it with the following JVM Option:

What’s the way to do this when I run the app from a Jenkins job?



With the assumption that user knows .jenkins file, I provide below the code snippet.

node {

.... Other code 

stage("development") {
                withEnv(['JENKINS_NODE_COOKIE=someName']) {
                    sh 'nohup ./mvnw spring-boot:run &'


For more details and reference, check below the link.

If you do not want to write .jenkins file, you can follow the link and setup manually.

In case of gradlew clean build, you can provide the the following command.

mvnw spring-boot:run