Changing Jenkins build number
Is there a way to change the build number that is sent via email after a job completes? The problem is that are product builds are NOT being done by Jenkins, so we want to be able to get the build number(ie. from a text file) and update the build number in Jenkins to match it. I have tried to set the build number:
set BUILD_NUMBER=45
But the email is still showing the build number that Jenkins originally set.
jenkins
add a comment |
Is there a way to change the build number that is sent via email after a job completes? The problem is that are product builds are NOT being done by Jenkins, so we want to be able to get the build number(ie. from a text file) and update the build number in Jenkins to match it. I have tried to set the build number:
set BUILD_NUMBER=45
But the email is still showing the build number that Jenkins originally set.
jenkins
add a comment |
Is there a way to change the build number that is sent via email after a job completes? The problem is that are product builds are NOT being done by Jenkins, so we want to be able to get the build number(ie. from a text file) and update the build number in Jenkins to match it. I have tried to set the build number:
set BUILD_NUMBER=45
But the email is still showing the build number that Jenkins originally set.
jenkins
Is there a way to change the build number that is sent via email after a job completes? The problem is that are product builds are NOT being done by Jenkins, so we want to be able to get the build number(ie. from a text file) and update the build number in Jenkins to match it. I have tried to set the build number:
set BUILD_NUMBER=45
But the email is still showing the build number that Jenkins originally set.
jenkins
jenkins
edited Oct 28 '13 at 21:49
Frederic Close
7,21424257
7,21424257
asked Oct 28 '13 at 21:30
erman8
5812716
5812716
add a comment |
add a comment |
6 Answers
6
active
oldest
votes
If you have access to the script console (Manage Jenkins -> Script Console), then you can do this following:
Jenkins.instance.getItemByFullName("YourJobName").updateNextBuildNumber(45)
7
I can verify this works perfectly to solve the problem. I manually copied build history between two jenkins servers, and on the new server nextBuildNumber was wrong. Running this allowed me to set a correct new nextBuildNumber, no jenkins config reload required.
– Phil Hollenback
May 24 '16 at 16:59
4
If you are using the GitHub plugin,"YourJobName"is"organization/repository/branchname".
– Ruud
Sep 20 '16 at 15:50
3
Works. The value can be verified without building using:Jenkins.instance.getItemByFullName("YourJobName").getNextBuildNumber()
– Daniel Alder
Mar 15 '17 at 14:51
3
I can confirm this is also working for MultiBranch-Pipelines. The "JobName" is listed on the top of the branch page: Full project name:PipelineName/BranchNameso it would beJenkins.instance.getItemByFullName("YourPipelineName/YourBranchName").updateNextBuildNumber(45)
– Markus
Aug 1 '17 at 14:54
1
@Quantic meta.stackoverflow.com/questions/356435/…
– Daniel Alder
Sep 12 '17 at 13:04
|
show 3 more comments
can be done with the plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Next+Build+Number+Plugin
more info:
http://www.alexlea.me/2010/10/howto-set-hudson-next-build-number.html
if you don't like the plugin:
If you want to change build number via nextBuildNumber file you should
"Reload Configuration from Disk" from "Manage Jenkins" page.
2
No need to use plugin.
– david.perez
Oct 7 '14 at 14:19
1
Thanks, you save my day.
– カオナシ
Nov 3 '14 at 20:58
1
This plugin is good. It's great.
– AechoLiu
Jun 28 '17 at 8:29
add a comment |
Under the job workspace folder, like:
C:Program Files (x86)Jenkinsjobsjob_name
there is a file named nextBuildNumber.
Setting the build number in the file and reloading the configuration from disk (Manage Jenkins menu) will force the next build you start to have the value from the file as BUILD_NUMBER.
1
Didn't work for me
– hfossli
Sep 17 '15 at 13:19
7
Did you reload the configuration from disk (Manage Jenkins menu) after changing the nextBuildNumber file?
– vezenkov
Sep 17 '15 at 18:59
Nope! I thought it happened automatically.
– hfossli
Sep 18 '15 at 8:13
This worked perfectly for me. You have to reboot the server before it takes affect.
– Hawkeye64
Nov 20 at 17:46
add a comment |
Perhaps a combination of these plugins may come in handy:
Parametrized build plugin - define some variable which holds your build number
Version number plugin - use the variable to change the build number
Build name setter plugin - use the variable to change the build number
Thanks a lot - I was able to use one of the plugins.
– erman8
Nov 1 '13 at 21:55
6
@erman8 - Which plugin did you use?
– randominstanceOfLivingThing
Jun 18 '14 at 16:26
add a comment |
If you have branch name including Forward Slash (using git flow for example), you will need to replace the Forward Slash with its Unicode character %2F within the branch name.
Here is an example for the pipeline My-Pipeline-Name and the branch release/my-release-branch-name
Jenkins.instance.getItemByFullName("My-Pipeline-Name/release%2Fmy-release-branch-name").updateNextBuildNumber(BUILD_NUMBER)
I was able to find out about this by running the following command which will list the different jobs (branches) for your pipeline
Jenkins.instance.getItem("My-Pipeline-Name").getAllJobs()
Hope it helps.
add a comment |
By USING ENVIRONMENTAL VARIABLES
$BUILD_NUMBER =4
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%2f19645430%2fchanging-jenkins-build-number%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you have access to the script console (Manage Jenkins -> Script Console), then you can do this following:
Jenkins.instance.getItemByFullName("YourJobName").updateNextBuildNumber(45)
7
I can verify this works perfectly to solve the problem. I manually copied build history between two jenkins servers, and on the new server nextBuildNumber was wrong. Running this allowed me to set a correct new nextBuildNumber, no jenkins config reload required.
– Phil Hollenback
May 24 '16 at 16:59
4
If you are using the GitHub plugin,"YourJobName"is"organization/repository/branchname".
– Ruud
Sep 20 '16 at 15:50
3
Works. The value can be verified without building using:Jenkins.instance.getItemByFullName("YourJobName").getNextBuildNumber()
– Daniel Alder
Mar 15 '17 at 14:51
3
I can confirm this is also working for MultiBranch-Pipelines. The "JobName" is listed on the top of the branch page: Full project name:PipelineName/BranchNameso it would beJenkins.instance.getItemByFullName("YourPipelineName/YourBranchName").updateNextBuildNumber(45)
– Markus
Aug 1 '17 at 14:54
1
@Quantic meta.stackoverflow.com/questions/356435/…
– Daniel Alder
Sep 12 '17 at 13:04
|
show 3 more comments
If you have access to the script console (Manage Jenkins -> Script Console), then you can do this following:
Jenkins.instance.getItemByFullName("YourJobName").updateNextBuildNumber(45)
7
I can verify this works perfectly to solve the problem. I manually copied build history between two jenkins servers, and on the new server nextBuildNumber was wrong. Running this allowed me to set a correct new nextBuildNumber, no jenkins config reload required.
– Phil Hollenback
May 24 '16 at 16:59
4
If you are using the GitHub plugin,"YourJobName"is"organization/repository/branchname".
– Ruud
Sep 20 '16 at 15:50
3
Works. The value can be verified without building using:Jenkins.instance.getItemByFullName("YourJobName").getNextBuildNumber()
– Daniel Alder
Mar 15 '17 at 14:51
3
I can confirm this is also working for MultiBranch-Pipelines. The "JobName" is listed on the top of the branch page: Full project name:PipelineName/BranchNameso it would beJenkins.instance.getItemByFullName("YourPipelineName/YourBranchName").updateNextBuildNumber(45)
– Markus
Aug 1 '17 at 14:54
1
@Quantic meta.stackoverflow.com/questions/356435/…
– Daniel Alder
Sep 12 '17 at 13:04
|
show 3 more comments
If you have access to the script console (Manage Jenkins -> Script Console), then you can do this following:
Jenkins.instance.getItemByFullName("YourJobName").updateNextBuildNumber(45)
If you have access to the script console (Manage Jenkins -> Script Console), then you can do this following:
Jenkins.instance.getItemByFullName("YourJobName").updateNextBuildNumber(45)
answered Apr 27 '16 at 22:03
l8nite
2,56511419
2,56511419
7
I can verify this works perfectly to solve the problem. I manually copied build history between two jenkins servers, and on the new server nextBuildNumber was wrong. Running this allowed me to set a correct new nextBuildNumber, no jenkins config reload required.
– Phil Hollenback
May 24 '16 at 16:59
4
If you are using the GitHub plugin,"YourJobName"is"organization/repository/branchname".
– Ruud
Sep 20 '16 at 15:50
3
Works. The value can be verified without building using:Jenkins.instance.getItemByFullName("YourJobName").getNextBuildNumber()
– Daniel Alder
Mar 15 '17 at 14:51
3
I can confirm this is also working for MultiBranch-Pipelines. The "JobName" is listed on the top of the branch page: Full project name:PipelineName/BranchNameso it would beJenkins.instance.getItemByFullName("YourPipelineName/YourBranchName").updateNextBuildNumber(45)
– Markus
Aug 1 '17 at 14:54
1
@Quantic meta.stackoverflow.com/questions/356435/…
– Daniel Alder
Sep 12 '17 at 13:04
|
show 3 more comments
7
I can verify this works perfectly to solve the problem. I manually copied build history between two jenkins servers, and on the new server nextBuildNumber was wrong. Running this allowed me to set a correct new nextBuildNumber, no jenkins config reload required.
– Phil Hollenback
May 24 '16 at 16:59
4
If you are using the GitHub plugin,"YourJobName"is"organization/repository/branchname".
– Ruud
Sep 20 '16 at 15:50
3
Works. The value can be verified without building using:Jenkins.instance.getItemByFullName("YourJobName").getNextBuildNumber()
– Daniel Alder
Mar 15 '17 at 14:51
3
I can confirm this is also working for MultiBranch-Pipelines. The "JobName" is listed on the top of the branch page: Full project name:PipelineName/BranchNameso it would beJenkins.instance.getItemByFullName("YourPipelineName/YourBranchName").updateNextBuildNumber(45)
– Markus
Aug 1 '17 at 14:54
1
@Quantic meta.stackoverflow.com/questions/356435/…
– Daniel Alder
Sep 12 '17 at 13:04
7
7
I can verify this works perfectly to solve the problem. I manually copied build history between two jenkins servers, and on the new server nextBuildNumber was wrong. Running this allowed me to set a correct new nextBuildNumber, no jenkins config reload required.
– Phil Hollenback
May 24 '16 at 16:59
I can verify this works perfectly to solve the problem. I manually copied build history between two jenkins servers, and on the new server nextBuildNumber was wrong. Running this allowed me to set a correct new nextBuildNumber, no jenkins config reload required.
– Phil Hollenback
May 24 '16 at 16:59
4
4
If you are using the GitHub plugin,
"YourJobName" is "organization/repository/branchname".– Ruud
Sep 20 '16 at 15:50
If you are using the GitHub plugin,
"YourJobName" is "organization/repository/branchname".– Ruud
Sep 20 '16 at 15:50
3
3
Works. The value can be verified without building using:
Jenkins.instance.getItemByFullName("YourJobName").getNextBuildNumber()– Daniel Alder
Mar 15 '17 at 14:51
Works. The value can be verified without building using:
Jenkins.instance.getItemByFullName("YourJobName").getNextBuildNumber()– Daniel Alder
Mar 15 '17 at 14:51
3
3
I can confirm this is also working for MultiBranch-Pipelines. The "JobName" is listed on the top of the branch page: Full project name:
PipelineName/BranchName so it would be Jenkins.instance.getItemByFullName("YourPipelineName/YourBranchName").updateNextBuildNumber(45)– Markus
Aug 1 '17 at 14:54
I can confirm this is also working for MultiBranch-Pipelines. The "JobName" is listed on the top of the branch page: Full project name:
PipelineName/BranchName so it would be Jenkins.instance.getItemByFullName("YourPipelineName/YourBranchName").updateNextBuildNumber(45)– Markus
Aug 1 '17 at 14:54
1
1
@Quantic meta.stackoverflow.com/questions/356435/…
– Daniel Alder
Sep 12 '17 at 13:04
@Quantic meta.stackoverflow.com/questions/356435/…
– Daniel Alder
Sep 12 '17 at 13:04
|
show 3 more comments
can be done with the plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Next+Build+Number+Plugin
more info:
http://www.alexlea.me/2010/10/howto-set-hudson-next-build-number.html
if you don't like the plugin:
If you want to change build number via nextBuildNumber file you should
"Reload Configuration from Disk" from "Manage Jenkins" page.
2
No need to use plugin.
– david.perez
Oct 7 '14 at 14:19
1
Thanks, you save my day.
– カオナシ
Nov 3 '14 at 20:58
1
This plugin is good. It's great.
– AechoLiu
Jun 28 '17 at 8:29
add a comment |
can be done with the plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Next+Build+Number+Plugin
more info:
http://www.alexlea.me/2010/10/howto-set-hudson-next-build-number.html
if you don't like the plugin:
If you want to change build number via nextBuildNumber file you should
"Reload Configuration from Disk" from "Manage Jenkins" page.
2
No need to use plugin.
– david.perez
Oct 7 '14 at 14:19
1
Thanks, you save my day.
– カオナシ
Nov 3 '14 at 20:58
1
This plugin is good. It's great.
– AechoLiu
Jun 28 '17 at 8:29
add a comment |
can be done with the plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Next+Build+Number+Plugin
more info:
http://www.alexlea.me/2010/10/howto-set-hudson-next-build-number.html
if you don't like the plugin:
If you want to change build number via nextBuildNumber file you should
"Reload Configuration from Disk" from "Manage Jenkins" page.
can be done with the plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Next+Build+Number+Plugin
more info:
http://www.alexlea.me/2010/10/howto-set-hudson-next-build-number.html
if you don't like the plugin:
If you want to change build number via nextBuildNumber file you should
"Reload Configuration from Disk" from "Manage Jenkins" page.
answered Apr 22 '14 at 13:40
mighq
8041012
8041012
2
No need to use plugin.
– david.perez
Oct 7 '14 at 14:19
1
Thanks, you save my day.
– カオナシ
Nov 3 '14 at 20:58
1
This plugin is good. It's great.
– AechoLiu
Jun 28 '17 at 8:29
add a comment |
2
No need to use plugin.
– david.perez
Oct 7 '14 at 14:19
1
Thanks, you save my day.
– カオナシ
Nov 3 '14 at 20:58
1
This plugin is good. It's great.
– AechoLiu
Jun 28 '17 at 8:29
2
2
No need to use plugin.
– david.perez
Oct 7 '14 at 14:19
No need to use plugin.
– david.perez
Oct 7 '14 at 14:19
1
1
Thanks, you save my day.
– カオナシ
Nov 3 '14 at 20:58
Thanks, you save my day.
– カオナシ
Nov 3 '14 at 20:58
1
1
This plugin is good. It's great.
– AechoLiu
Jun 28 '17 at 8:29
This plugin is good. It's great.
– AechoLiu
Jun 28 '17 at 8:29
add a comment |
Under the job workspace folder, like:
C:Program Files (x86)Jenkinsjobsjob_name
there is a file named nextBuildNumber.
Setting the build number in the file and reloading the configuration from disk (Manage Jenkins menu) will force the next build you start to have the value from the file as BUILD_NUMBER.
1
Didn't work for me
– hfossli
Sep 17 '15 at 13:19
7
Did you reload the configuration from disk (Manage Jenkins menu) after changing the nextBuildNumber file?
– vezenkov
Sep 17 '15 at 18:59
Nope! I thought it happened automatically.
– hfossli
Sep 18 '15 at 8:13
This worked perfectly for me. You have to reboot the server before it takes affect.
– Hawkeye64
Nov 20 at 17:46
add a comment |
Under the job workspace folder, like:
C:Program Files (x86)Jenkinsjobsjob_name
there is a file named nextBuildNumber.
Setting the build number in the file and reloading the configuration from disk (Manage Jenkins menu) will force the next build you start to have the value from the file as BUILD_NUMBER.
1
Didn't work for me
– hfossli
Sep 17 '15 at 13:19
7
Did you reload the configuration from disk (Manage Jenkins menu) after changing the nextBuildNumber file?
– vezenkov
Sep 17 '15 at 18:59
Nope! I thought it happened automatically.
– hfossli
Sep 18 '15 at 8:13
This worked perfectly for me. You have to reboot the server before it takes affect.
– Hawkeye64
Nov 20 at 17:46
add a comment |
Under the job workspace folder, like:
C:Program Files (x86)Jenkinsjobsjob_name
there is a file named nextBuildNumber.
Setting the build number in the file and reloading the configuration from disk (Manage Jenkins menu) will force the next build you start to have the value from the file as BUILD_NUMBER.
Under the job workspace folder, like:
C:Program Files (x86)Jenkinsjobsjob_name
there is a file named nextBuildNumber.
Setting the build number in the file and reloading the configuration from disk (Manage Jenkins menu) will force the next build you start to have the value from the file as BUILD_NUMBER.
edited Sep 18 '15 at 8:14
hfossli
17.8k898119
17.8k898119
answered Aug 6 '15 at 6:10
vezenkov
2,2522024
2,2522024
1
Didn't work for me
– hfossli
Sep 17 '15 at 13:19
7
Did you reload the configuration from disk (Manage Jenkins menu) after changing the nextBuildNumber file?
– vezenkov
Sep 17 '15 at 18:59
Nope! I thought it happened automatically.
– hfossli
Sep 18 '15 at 8:13
This worked perfectly for me. You have to reboot the server before it takes affect.
– Hawkeye64
Nov 20 at 17:46
add a comment |
1
Didn't work for me
– hfossli
Sep 17 '15 at 13:19
7
Did you reload the configuration from disk (Manage Jenkins menu) after changing the nextBuildNumber file?
– vezenkov
Sep 17 '15 at 18:59
Nope! I thought it happened automatically.
– hfossli
Sep 18 '15 at 8:13
This worked perfectly for me. You have to reboot the server before it takes affect.
– Hawkeye64
Nov 20 at 17:46
1
1
Didn't work for me
– hfossli
Sep 17 '15 at 13:19
Didn't work for me
– hfossli
Sep 17 '15 at 13:19
7
7
Did you reload the configuration from disk (Manage Jenkins menu) after changing the nextBuildNumber file?
– vezenkov
Sep 17 '15 at 18:59
Did you reload the configuration from disk (Manage Jenkins menu) after changing the nextBuildNumber file?
– vezenkov
Sep 17 '15 at 18:59
Nope! I thought it happened automatically.
– hfossli
Sep 18 '15 at 8:13
Nope! I thought it happened automatically.
– hfossli
Sep 18 '15 at 8:13
This worked perfectly for me. You have to reboot the server before it takes affect.
– Hawkeye64
Nov 20 at 17:46
This worked perfectly for me. You have to reboot the server before it takes affect.
– Hawkeye64
Nov 20 at 17:46
add a comment |
Perhaps a combination of these plugins may come in handy:
Parametrized build plugin - define some variable which holds your build number
Version number plugin - use the variable to change the build number
Build name setter plugin - use the variable to change the build number
Thanks a lot - I was able to use one of the plugins.
– erman8
Nov 1 '13 at 21:55
6
@erman8 - Which plugin did you use?
– randominstanceOfLivingThing
Jun 18 '14 at 16:26
add a comment |
Perhaps a combination of these plugins may come in handy:
Parametrized build plugin - define some variable which holds your build number
Version number plugin - use the variable to change the build number
Build name setter plugin - use the variable to change the build number
Thanks a lot - I was able to use one of the plugins.
– erman8
Nov 1 '13 at 21:55
6
@erman8 - Which plugin did you use?
– randominstanceOfLivingThing
Jun 18 '14 at 16:26
add a comment |
Perhaps a combination of these plugins may come in handy:
Parametrized build plugin - define some variable which holds your build number
Version number plugin - use the variable to change the build number
Build name setter plugin - use the variable to change the build number
Perhaps a combination of these plugins may come in handy:
Parametrized build plugin - define some variable which holds your build number
Version number plugin - use the variable to change the build number
Build name setter plugin - use the variable to change the build number
answered Oct 28 '13 at 22:41
Morfic
11.6k32645
11.6k32645
Thanks a lot - I was able to use one of the plugins.
– erman8
Nov 1 '13 at 21:55
6
@erman8 - Which plugin did you use?
– randominstanceOfLivingThing
Jun 18 '14 at 16:26
add a comment |
Thanks a lot - I was able to use one of the plugins.
– erman8
Nov 1 '13 at 21:55
6
@erman8 - Which plugin did you use?
– randominstanceOfLivingThing
Jun 18 '14 at 16:26
Thanks a lot - I was able to use one of the plugins.
– erman8
Nov 1 '13 at 21:55
Thanks a lot - I was able to use one of the plugins.
– erman8
Nov 1 '13 at 21:55
6
6
@erman8 - Which plugin did you use?
– randominstanceOfLivingThing
Jun 18 '14 at 16:26
@erman8 - Which plugin did you use?
– randominstanceOfLivingThing
Jun 18 '14 at 16:26
add a comment |
If you have branch name including Forward Slash (using git flow for example), you will need to replace the Forward Slash with its Unicode character %2F within the branch name.
Here is an example for the pipeline My-Pipeline-Name and the branch release/my-release-branch-name
Jenkins.instance.getItemByFullName("My-Pipeline-Name/release%2Fmy-release-branch-name").updateNextBuildNumber(BUILD_NUMBER)
I was able to find out about this by running the following command which will list the different jobs (branches) for your pipeline
Jenkins.instance.getItem("My-Pipeline-Name").getAllJobs()
Hope it helps.
add a comment |
If you have branch name including Forward Slash (using git flow for example), you will need to replace the Forward Slash with its Unicode character %2F within the branch name.
Here is an example for the pipeline My-Pipeline-Name and the branch release/my-release-branch-name
Jenkins.instance.getItemByFullName("My-Pipeline-Name/release%2Fmy-release-branch-name").updateNextBuildNumber(BUILD_NUMBER)
I was able to find out about this by running the following command which will list the different jobs (branches) for your pipeline
Jenkins.instance.getItem("My-Pipeline-Name").getAllJobs()
Hope it helps.
add a comment |
If you have branch name including Forward Slash (using git flow for example), you will need to replace the Forward Slash with its Unicode character %2F within the branch name.
Here is an example for the pipeline My-Pipeline-Name and the branch release/my-release-branch-name
Jenkins.instance.getItemByFullName("My-Pipeline-Name/release%2Fmy-release-branch-name").updateNextBuildNumber(BUILD_NUMBER)
I was able to find out about this by running the following command which will list the different jobs (branches) for your pipeline
Jenkins.instance.getItem("My-Pipeline-Name").getAllJobs()
Hope it helps.
If you have branch name including Forward Slash (using git flow for example), you will need to replace the Forward Slash with its Unicode character %2F within the branch name.
Here is an example for the pipeline My-Pipeline-Name and the branch release/my-release-branch-name
Jenkins.instance.getItemByFullName("My-Pipeline-Name/release%2Fmy-release-branch-name").updateNextBuildNumber(BUILD_NUMBER)
I was able to find out about this by running the following command which will list the different jobs (branches) for your pipeline
Jenkins.instance.getItem("My-Pipeline-Name").getAllJobs()
Hope it helps.
answered Nov 20 at 17:54
DaWyz
313
313
add a comment |
add a comment |
By USING ENVIRONMENTAL VARIABLES
$BUILD_NUMBER =4
add a comment |
By USING ENVIRONMENTAL VARIABLES
$BUILD_NUMBER =4
add a comment |
By USING ENVIRONMENTAL VARIABLES
$BUILD_NUMBER =4
By USING ENVIRONMENTAL VARIABLES
$BUILD_NUMBER =4
answered Jul 29 at 21:56
ksr
443
443
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f19645430%2fchanging-jenkins-build-number%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