How to set build name in Jenkins Job DSL?
According to the documentation in https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.wrapper.MavenWrapperContext.buildName
Following code should update build name in Build History in Jenkins jobs:
// define the build name based on the build number and an environment variable
job('example') {
wrappers {
buildName('#${BUILD_NUMBER} on ${ENV,var="BRANCH"}')
}
}
Unfortunately, it is not doing it.
Is there any way to change build name from Jenkins Job DSL script?
I know I can change it from Jenkins Pipeline Script but it is not needed for me in this particular job. All I use in the job is steps.
steps {
shell("docker cp ...")
shell("git clone ...")
...
}
I would like to emphasise I am looking for a native Jenkins Job DSL solution and not a Jenkins Pipeline Script one or any other hacky way like manipulation of environment variables.
jenkins jenkins-job-dsl
add a comment |
According to the documentation in https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.wrapper.MavenWrapperContext.buildName
Following code should update build name in Build History in Jenkins jobs:
// define the build name based on the build number and an environment variable
job('example') {
wrappers {
buildName('#${BUILD_NUMBER} on ${ENV,var="BRANCH"}')
}
}
Unfortunately, it is not doing it.
Is there any way to change build name from Jenkins Job DSL script?
I know I can change it from Jenkins Pipeline Script but it is not needed for me in this particular job. All I use in the job is steps.
steps {
shell("docker cp ...")
shell("git clone ...")
...
}
I would like to emphasise I am looking for a native Jenkins Job DSL solution and not a Jenkins Pipeline Script one or any other hacky way like manipulation of environment variables.
jenkins jenkins-job-dsl
Possible duplicate of How to customize Jenkins build name?
– Michael
Nov 24 '18 at 6:29
The answer you have pointed to is related to Jenkins Pipeline scripts or has some hacky ways of changing the build name. I was hoping for a solution supported by Jenkins Job DSL script natively.
– firen
Nov 26 '18 at 22:22
add a comment |
According to the documentation in https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.wrapper.MavenWrapperContext.buildName
Following code should update build name in Build History in Jenkins jobs:
// define the build name based on the build number and an environment variable
job('example') {
wrappers {
buildName('#${BUILD_NUMBER} on ${ENV,var="BRANCH"}')
}
}
Unfortunately, it is not doing it.
Is there any way to change build name from Jenkins Job DSL script?
I know I can change it from Jenkins Pipeline Script but it is not needed for me in this particular job. All I use in the job is steps.
steps {
shell("docker cp ...")
shell("git clone ...")
...
}
I would like to emphasise I am looking for a native Jenkins Job DSL solution and not a Jenkins Pipeline Script one or any other hacky way like manipulation of environment variables.
jenkins jenkins-job-dsl
According to the documentation in https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.wrapper.MavenWrapperContext.buildName
Following code should update build name in Build History in Jenkins jobs:
// define the build name based on the build number and an environment variable
job('example') {
wrappers {
buildName('#${BUILD_NUMBER} on ${ENV,var="BRANCH"}')
}
}
Unfortunately, it is not doing it.
Is there any way to change build name from Jenkins Job DSL script?
I know I can change it from Jenkins Pipeline Script but it is not needed for me in this particular job. All I use in the job is steps.
steps {
shell("docker cp ...")
shell("git clone ...")
...
}
I would like to emphasise I am looking for a native Jenkins Job DSL solution and not a Jenkins Pipeline Script one or any other hacky way like manipulation of environment variables.
jenkins jenkins-job-dsl
jenkins jenkins-job-dsl
edited Nov 26 '18 at 22:25
firen
asked Nov 23 '18 at 18:15
firenfiren
5972724
5972724
Possible duplicate of How to customize Jenkins build name?
– Michael
Nov 24 '18 at 6:29
The answer you have pointed to is related to Jenkins Pipeline scripts or has some hacky ways of changing the build name. I was hoping for a solution supported by Jenkins Job DSL script natively.
– firen
Nov 26 '18 at 22:22
add a comment |
Possible duplicate of How to customize Jenkins build name?
– Michael
Nov 24 '18 at 6:29
The answer you have pointed to is related to Jenkins Pipeline scripts or has some hacky ways of changing the build name. I was hoping for a solution supported by Jenkins Job DSL script natively.
– firen
Nov 26 '18 at 22:22
Possible duplicate of How to customize Jenkins build name?
– Michael
Nov 24 '18 at 6:29
Possible duplicate of How to customize Jenkins build name?
– Michael
Nov 24 '18 at 6:29
The answer you have pointed to is related to Jenkins Pipeline scripts or has some hacky ways of changing the build name. I was hoping for a solution supported by Jenkins Job DSL script natively.
– firen
Nov 26 '18 at 22:22
The answer you have pointed to is related to Jenkins Pipeline scripts or has some hacky ways of changing the build name. I was hoping for a solution supported by Jenkins Job DSL script natively.
– firen
Nov 26 '18 at 22:22
add a comment |
3 Answers
3
active
oldest
votes
I have managed to solve my issue today.
The script did not work because it requires build-name-setter plugin installed in Jenkins. After I have installed it works perfectly.
Unfortunately, by default jobdsl processor does not inform about missing plugins. The parameter enabling that is described here https://issues.jenkins-ci.org/browse/JENKINS-37417
add a comment |
Here's a minimal pipeline changing the build's display name and description. IMHO this is pretty straight forward.
pipeline {
agent any
environment {
VERSION = "1.2.3-SNAPSHOT"
}
stages {
stage("set build name") {
steps {
script {
currentBuild.displayName = "v${env.VERSION}"
currentBuild.description = "#${BUILD_NUMBER} (v${env.VERSION})"
}
}
}
}
}
It results in the following representation in Jenkins' UI:
jenkinsci.github.io/job-dsl-plugin/#method/… script seams to not be part of steps element
– firen
Dec 4 '18 at 15:34
@firen you linked to a job DSL documentation page. My example is in pipeline DSL andscript
is a valid step (see jenkins.io/doc/pipeline/steps/pipeline-model-definition/…)
– Michael
Dec 4 '18 at 15:38
add a comment |
setBuildName("your_build_name")
in a groovyPostBuild step may do the trick as well.
Needs Groovy Postbuild Plugin.
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%2f53451345%2fhow-to-set-build-name-in-jenkins-job-dsl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I have managed to solve my issue today.
The script did not work because it requires build-name-setter plugin installed in Jenkins. After I have installed it works perfectly.
Unfortunately, by default jobdsl processor does not inform about missing plugins. The parameter enabling that is described here https://issues.jenkins-ci.org/browse/JENKINS-37417
add a comment |
I have managed to solve my issue today.
The script did not work because it requires build-name-setter plugin installed in Jenkins. After I have installed it works perfectly.
Unfortunately, by default jobdsl processor does not inform about missing plugins. The parameter enabling that is described here https://issues.jenkins-ci.org/browse/JENKINS-37417
add a comment |
I have managed to solve my issue today.
The script did not work because it requires build-name-setter plugin installed in Jenkins. After I have installed it works perfectly.
Unfortunately, by default jobdsl processor does not inform about missing plugins. The parameter enabling that is described here https://issues.jenkins-ci.org/browse/JENKINS-37417
I have managed to solve my issue today.
The script did not work because it requires build-name-setter plugin installed in Jenkins. After I have installed it works perfectly.
Unfortunately, by default jobdsl processor does not inform about missing plugins. The parameter enabling that is described here https://issues.jenkins-ci.org/browse/JENKINS-37417
answered Dec 4 '18 at 19:36
firenfiren
5972724
5972724
add a comment |
add a comment |
Here's a minimal pipeline changing the build's display name and description. IMHO this is pretty straight forward.
pipeline {
agent any
environment {
VERSION = "1.2.3-SNAPSHOT"
}
stages {
stage("set build name") {
steps {
script {
currentBuild.displayName = "v${env.VERSION}"
currentBuild.description = "#${BUILD_NUMBER} (v${env.VERSION})"
}
}
}
}
}
It results in the following representation in Jenkins' UI:
jenkinsci.github.io/job-dsl-plugin/#method/… script seams to not be part of steps element
– firen
Dec 4 '18 at 15:34
@firen you linked to a job DSL documentation page. My example is in pipeline DSL andscript
is a valid step (see jenkins.io/doc/pipeline/steps/pipeline-model-definition/…)
– Michael
Dec 4 '18 at 15:38
add a comment |
Here's a minimal pipeline changing the build's display name and description. IMHO this is pretty straight forward.
pipeline {
agent any
environment {
VERSION = "1.2.3-SNAPSHOT"
}
stages {
stage("set build name") {
steps {
script {
currentBuild.displayName = "v${env.VERSION}"
currentBuild.description = "#${BUILD_NUMBER} (v${env.VERSION})"
}
}
}
}
}
It results in the following representation in Jenkins' UI:
jenkinsci.github.io/job-dsl-plugin/#method/… script seams to not be part of steps element
– firen
Dec 4 '18 at 15:34
@firen you linked to a job DSL documentation page. My example is in pipeline DSL andscript
is a valid step (see jenkins.io/doc/pipeline/steps/pipeline-model-definition/…)
– Michael
Dec 4 '18 at 15:38
add a comment |
Here's a minimal pipeline changing the build's display name and description. IMHO this is pretty straight forward.
pipeline {
agent any
environment {
VERSION = "1.2.3-SNAPSHOT"
}
stages {
stage("set build name") {
steps {
script {
currentBuild.displayName = "v${env.VERSION}"
currentBuild.description = "#${BUILD_NUMBER} (v${env.VERSION})"
}
}
}
}
}
It results in the following representation in Jenkins' UI:
Here's a minimal pipeline changing the build's display name and description. IMHO this is pretty straight forward.
pipeline {
agent any
environment {
VERSION = "1.2.3-SNAPSHOT"
}
stages {
stage("set build name") {
steps {
script {
currentBuild.displayName = "v${env.VERSION}"
currentBuild.description = "#${BUILD_NUMBER} (v${env.VERSION})"
}
}
}
}
}
It results in the following representation in Jenkins' UI:
answered Nov 30 '18 at 12:54
MichaelMichael
1,2161912
1,2161912
jenkinsci.github.io/job-dsl-plugin/#method/… script seams to not be part of steps element
– firen
Dec 4 '18 at 15:34
@firen you linked to a job DSL documentation page. My example is in pipeline DSL andscript
is a valid step (see jenkins.io/doc/pipeline/steps/pipeline-model-definition/…)
– Michael
Dec 4 '18 at 15:38
add a comment |
jenkinsci.github.io/job-dsl-plugin/#method/… script seams to not be part of steps element
– firen
Dec 4 '18 at 15:34
@firen you linked to a job DSL documentation page. My example is in pipeline DSL andscript
is a valid step (see jenkins.io/doc/pipeline/steps/pipeline-model-definition/…)
– Michael
Dec 4 '18 at 15:38
jenkinsci.github.io/job-dsl-plugin/#method/… script seams to not be part of steps element
– firen
Dec 4 '18 at 15:34
jenkinsci.github.io/job-dsl-plugin/#method/… script seams to not be part of steps element
– firen
Dec 4 '18 at 15:34
@firen you linked to a job DSL documentation page. My example is in pipeline DSL and
script
is a valid step (see jenkins.io/doc/pipeline/steps/pipeline-model-definition/…)– Michael
Dec 4 '18 at 15:38
@firen you linked to a job DSL documentation page. My example is in pipeline DSL and
script
is a valid step (see jenkins.io/doc/pipeline/steps/pipeline-model-definition/…)– Michael
Dec 4 '18 at 15:38
add a comment |
setBuildName("your_build_name")
in a groovyPostBuild step may do the trick as well.
Needs Groovy Postbuild Plugin.
add a comment |
setBuildName("your_build_name")
in a groovyPostBuild step may do the trick as well.
Needs Groovy Postbuild Plugin.
add a comment |
setBuildName("your_build_name")
in a groovyPostBuild step may do the trick as well.
Needs Groovy Postbuild Plugin.
setBuildName("your_build_name")
in a groovyPostBuild step may do the trick as well.
Needs Groovy Postbuild Plugin.
answered Jan 29 at 14:49
lenkovilenkovi
1402310
1402310
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%2f53451345%2fhow-to-set-build-name-in-jenkins-job-dsl%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
Possible duplicate of How to customize Jenkins build name?
– Michael
Nov 24 '18 at 6:29
The answer you have pointed to is related to Jenkins Pipeline scripts or has some hacky ways of changing the build name. I was hoping for a solution supported by Jenkins Job DSL script natively.
– firen
Nov 26 '18 at 22:22