how to change sonarqube projectVersion number dynamically in jenkins
i tried updating sonarqube version dynamically in jenkins by adding sonar.projectVersion=${project.version} suggested at https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Gradle or sonar.projectVersion=${$APP_BUILD_NUMBER} here APP_BUILD_NUMBER environmental variable but no use it considered as is version name.
Full Analysis property
# required metadata
sonar.projectKey=myproject
sonar.projectName=myproject
sonar.projectVersion=2.0.2
sonar.sourceEncoding=UTF-8
# path to source directories (required)
sonar.sources=src/main/java
# List of the module identifiers
sonar.modules=app,ui
ui.sonar.projectBaseDir=ui
# Properties can obviously be overriden for
# each module - just prefix them with the module ID
app.sonar.projectName=App
# Uncomment this line to analyse a project which is not a java project.
# The value of the property must be the key of the language.
sonar.language=java
# java version used by source files:
sonar.java.source=1.8
jenkins sonarqube sonarqube-scan
add a comment |
i tried updating sonarqube version dynamically in jenkins by adding sonar.projectVersion=${project.version} suggested at https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Gradle or sonar.projectVersion=${$APP_BUILD_NUMBER} here APP_BUILD_NUMBER environmental variable but no use it considered as is version name.
Full Analysis property
# required metadata
sonar.projectKey=myproject
sonar.projectName=myproject
sonar.projectVersion=2.0.2
sonar.sourceEncoding=UTF-8
# path to source directories (required)
sonar.sources=src/main/java
# List of the module identifiers
sonar.modules=app,ui
ui.sonar.projectBaseDir=ui
# Properties can obviously be overriden for
# each module - just prefix them with the module ID
app.sonar.projectName=App
# Uncomment this line to analyse a project which is not a java project.
# The value of the property must be the key of the language.
sonar.language=java
# java version used by source files:
sonar.java.source=1.8
jenkins sonarqube sonarqube-scan
can you please provide your jenkins configuration with screenshots. and elaborate if you are using a sonar-project.properties file, or if you inject other settings?
– Simon Schrottner
May 7 '18 at 11:08
You can use a shell script to change the content of a text file. You can create a variable and inject it into the sonar properties file and get it done.
– Vighnesh Pai
May 7 '18 at 11:21
add a comment |
i tried updating sonarqube version dynamically in jenkins by adding sonar.projectVersion=${project.version} suggested at https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Gradle or sonar.projectVersion=${$APP_BUILD_NUMBER} here APP_BUILD_NUMBER environmental variable but no use it considered as is version name.
Full Analysis property
# required metadata
sonar.projectKey=myproject
sonar.projectName=myproject
sonar.projectVersion=2.0.2
sonar.sourceEncoding=UTF-8
# path to source directories (required)
sonar.sources=src/main/java
# List of the module identifiers
sonar.modules=app,ui
ui.sonar.projectBaseDir=ui
# Properties can obviously be overriden for
# each module - just prefix them with the module ID
app.sonar.projectName=App
# Uncomment this line to analyse a project which is not a java project.
# The value of the property must be the key of the language.
sonar.language=java
# java version used by source files:
sonar.java.source=1.8
jenkins sonarqube sonarqube-scan
i tried updating sonarqube version dynamically in jenkins by adding sonar.projectVersion=${project.version} suggested at https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Gradle or sonar.projectVersion=${$APP_BUILD_NUMBER} here APP_BUILD_NUMBER environmental variable but no use it considered as is version name.
Full Analysis property
# required metadata
sonar.projectKey=myproject
sonar.projectName=myproject
sonar.projectVersion=2.0.2
sonar.sourceEncoding=UTF-8
# path to source directories (required)
sonar.sources=src/main/java
# List of the module identifiers
sonar.modules=app,ui
ui.sonar.projectBaseDir=ui
# Properties can obviously be overriden for
# each module - just prefix them with the module ID
app.sonar.projectName=App
# Uncomment this line to analyse a project which is not a java project.
# The value of the property must be the key of the language.
sonar.language=java
# java version used by source files:
sonar.java.source=1.8
jenkins sonarqube sonarqube-scan
jenkins sonarqube sonarqube-scan
asked May 7 '18 at 6:55
KrishnanKrishnan
51
51
can you please provide your jenkins configuration with screenshots. and elaborate if you are using a sonar-project.properties file, or if you inject other settings?
– Simon Schrottner
May 7 '18 at 11:08
You can use a shell script to change the content of a text file. You can create a variable and inject it into the sonar properties file and get it done.
– Vighnesh Pai
May 7 '18 at 11:21
add a comment |
can you please provide your jenkins configuration with screenshots. and elaborate if you are using a sonar-project.properties file, or if you inject other settings?
– Simon Schrottner
May 7 '18 at 11:08
You can use a shell script to change the content of a text file. You can create a variable and inject it into the sonar properties file and get it done.
– Vighnesh Pai
May 7 '18 at 11:21
can you please provide your jenkins configuration with screenshots. and elaborate if you are using a sonar-project.properties file, or if you inject other settings?
– Simon Schrottner
May 7 '18 at 11:08
can you please provide your jenkins configuration with screenshots. and elaborate if you are using a sonar-project.properties file, or if you inject other settings?
– Simon Schrottner
May 7 '18 at 11:08
You can use a shell script to change the content of a text file. You can create a variable and inject it into the sonar properties file and get it done.
– Vighnesh Pai
May 7 '18 at 11:21
You can use a shell script to change the content of a text file. You can create a variable and inject it into the sonar properties file and get it done.
– Vighnesh Pai
May 7 '18 at 11:21
add a comment |
2 Answers
2
active
oldest
votes
More detailed question would have helped to answer better. Here I made assumptions to answer better.
I assumed, dynamic version name that you are trying to update is jenkins build number. which is accessible via jenkins environment variable ${BUILD_NUMBER}. You can directly use this in "Execute Shell" (i.e) echo ${BUILD_NUMBER}
will work.
You can use other environment variables too. ex: ${BUILD_TAG}. you can find the list of jenkins environment variables are available http://JENKINS-URL/env-vars.html/
These environment variables are available to your build script (i.e) ANT, Maven, Gradle, etc as well. Just make sure, you have used proper way to access environment variables inside the build script.
For Ant:
<property environment="env"/>
<property name="sonar.projectVersion" value=${env.BUILD_NUMBER}"/>
add a comment |
@Simon Schrottner
We have used following in Jenkins (Note: we have used Gradle)
sonar.projectKey=$JOB_NAME
sonar.projectName=$JOB_NAME
sonar.projectVersion=$BUILD_NUMBER
sonar.exclusions=vendor/**, storage/**, resources/**
sonar.language=java
sonar.sources=$WORKSPACE
sonar.sourceEncoding=UTF-8
sonar.java.binaries=$WORKSPACE/build/classes/java/main
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50208602%2fhow-to-change-sonarqube-projectversion-number-dynamically-in-jenkins%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
More detailed question would have helped to answer better. Here I made assumptions to answer better.
I assumed, dynamic version name that you are trying to update is jenkins build number. which is accessible via jenkins environment variable ${BUILD_NUMBER}. You can directly use this in "Execute Shell" (i.e) echo ${BUILD_NUMBER}
will work.
You can use other environment variables too. ex: ${BUILD_TAG}. you can find the list of jenkins environment variables are available http://JENKINS-URL/env-vars.html/
These environment variables are available to your build script (i.e) ANT, Maven, Gradle, etc as well. Just make sure, you have used proper way to access environment variables inside the build script.
For Ant:
<property environment="env"/>
<property name="sonar.projectVersion" value=${env.BUILD_NUMBER}"/>
add a comment |
More detailed question would have helped to answer better. Here I made assumptions to answer better.
I assumed, dynamic version name that you are trying to update is jenkins build number. which is accessible via jenkins environment variable ${BUILD_NUMBER}. You can directly use this in "Execute Shell" (i.e) echo ${BUILD_NUMBER}
will work.
You can use other environment variables too. ex: ${BUILD_TAG}. you can find the list of jenkins environment variables are available http://JENKINS-URL/env-vars.html/
These environment variables are available to your build script (i.e) ANT, Maven, Gradle, etc as well. Just make sure, you have used proper way to access environment variables inside the build script.
For Ant:
<property environment="env"/>
<property name="sonar.projectVersion" value=${env.BUILD_NUMBER}"/>
add a comment |
More detailed question would have helped to answer better. Here I made assumptions to answer better.
I assumed, dynamic version name that you are trying to update is jenkins build number. which is accessible via jenkins environment variable ${BUILD_NUMBER}. You can directly use this in "Execute Shell" (i.e) echo ${BUILD_NUMBER}
will work.
You can use other environment variables too. ex: ${BUILD_TAG}. you can find the list of jenkins environment variables are available http://JENKINS-URL/env-vars.html/
These environment variables are available to your build script (i.e) ANT, Maven, Gradle, etc as well. Just make sure, you have used proper way to access environment variables inside the build script.
For Ant:
<property environment="env"/>
<property name="sonar.projectVersion" value=${env.BUILD_NUMBER}"/>
More detailed question would have helped to answer better. Here I made assumptions to answer better.
I assumed, dynamic version name that you are trying to update is jenkins build number. which is accessible via jenkins environment variable ${BUILD_NUMBER}. You can directly use this in "Execute Shell" (i.e) echo ${BUILD_NUMBER}
will work.
You can use other environment variables too. ex: ${BUILD_TAG}. you can find the list of jenkins environment variables are available http://JENKINS-URL/env-vars.html/
These environment variables are available to your build script (i.e) ANT, Maven, Gradle, etc as well. Just make sure, you have used proper way to access environment variables inside the build script.
For Ant:
<property environment="env"/>
<property name="sonar.projectVersion" value=${env.BUILD_NUMBER}"/>
answered May 7 '18 at 12:06
FidelFidel
6821511
6821511
add a comment |
add a comment |
@Simon Schrottner
We have used following in Jenkins (Note: we have used Gradle)
sonar.projectKey=$JOB_NAME
sonar.projectName=$JOB_NAME
sonar.projectVersion=$BUILD_NUMBER
sonar.exclusions=vendor/**, storage/**, resources/**
sonar.language=java
sonar.sources=$WORKSPACE
sonar.sourceEncoding=UTF-8
sonar.java.binaries=$WORKSPACE/build/classes/java/main
add a comment |
@Simon Schrottner
We have used following in Jenkins (Note: we have used Gradle)
sonar.projectKey=$JOB_NAME
sonar.projectName=$JOB_NAME
sonar.projectVersion=$BUILD_NUMBER
sonar.exclusions=vendor/**, storage/**, resources/**
sonar.language=java
sonar.sources=$WORKSPACE
sonar.sourceEncoding=UTF-8
sonar.java.binaries=$WORKSPACE/build/classes/java/main
add a comment |
@Simon Schrottner
We have used following in Jenkins (Note: we have used Gradle)
sonar.projectKey=$JOB_NAME
sonar.projectName=$JOB_NAME
sonar.projectVersion=$BUILD_NUMBER
sonar.exclusions=vendor/**, storage/**, resources/**
sonar.language=java
sonar.sources=$WORKSPACE
sonar.sourceEncoding=UTF-8
sonar.java.binaries=$WORKSPACE/build/classes/java/main
@Simon Schrottner
We have used following in Jenkins (Note: we have used Gradle)
sonar.projectKey=$JOB_NAME
sonar.projectName=$JOB_NAME
sonar.projectVersion=$BUILD_NUMBER
sonar.exclusions=vendor/**, storage/**, resources/**
sonar.language=java
sonar.sources=$WORKSPACE
sonar.sourceEncoding=UTF-8
sonar.java.binaries=$WORKSPACE/build/classes/java/main
answered Jan 2 at 9:14
Mahendra KoratMahendra Korat
3118
3118
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50208602%2fhow-to-change-sonarqube-projectversion-number-dynamically-in-jenkins%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
can you please provide your jenkins configuration with screenshots. and elaborate if you are using a sonar-project.properties file, or if you inject other settings?
– Simon Schrottner
May 7 '18 at 11:08
You can use a shell script to change the content of a text file. You can create a variable and inject it into the sonar properties file and get it done.
– Vighnesh Pai
May 7 '18 at 11:21