jenkinsci / build-name-setter-plugin

Build Name Setter Plugin for Jenkins CI
https://plugins.jenkins.io/build-name-setter/
MIT License
34 stars 51 forks source link

After applying the plugin, I see no "set build name" section in my pipeline. #72

Closed davehouser1 closed 2 years ago

davehouser1 commented 2 years ago

Jenkins and plugins versions report

Environment ```text Plugin version 2.2.0 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Ubuntu 18.04 Running on Docker image jenkins/jenkins:lts Running version Jenkins 2.319.1

Reproduction steps

  1. Download the latest plugin from here , version 2.2.0
  2. Installed the plugin manually.
  3. Went to my job, configure settings, I see no "set build name" section anywhere.

Expected Results

After I install the plugin I should see "set build name" section.

Actual Results

There is no "set build name" section.

Anything else?

No response

damianszczepanik commented 2 years ago

Did you try sample code https://github.com/jenkinsci/build-name-setter-plugin ?

davehouser1 commented 2 years ago

@damianszczepanik, I did not put any of the pipline code in my Jenkinsfile. Its not clear if I needed to or not, is this a requirement? I thought I could just load the plugin and the "set build name" setting would show up in the job settings. Is this not the case?

damianszczepanik commented 2 years ago

Readme file provides how to configure this with pipeline and classic job. I have checked now and both are still there

davehouser1 commented 2 years ago

It still does not work for me, I am doing something wrong. I applied the pipeline settings like the README shows:

pipeline {
agent {label 'node2'}
    options {
        ansiColor('xterm')
    }
    stages {
        stage('Set branch name') {
            steps {
                buildName "${GERRIT_CHANGE_SUBJECT}"
                buildDescription "Executed @ ${NODE_NAME}"
            }
        }
    }
    post {
        always {
            script {
                currentBuild.result = currentBuild.result ?: 'SUCCESS'
                notifyBitbucket()
            }
        }
    }
}

But when I run the build I get this error:

groovy.lang.MissingPropertyException: No such property: GERRIT_CHANGE_SUBJECT for class: groovy.lang.Binding
    at groovy.lang.Binding.getVariable(Binding.java:63)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:271)
    at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:353)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:357)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:333)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:333)
    at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
    at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
    at WorkflowScript.run(WorkflowScript:27)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.delegateAndExecute(ModelInterpreter.groovy:137)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.executeSingleStage(ModelInterpreter.groovy:666)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.catchRequiredContextForNode(ModelInterpreter.groovy:395)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.catchRequiredContextForNode(ModelInterpreter.groovy:393)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.executeSingleStage(ModelInterpreter.groovy:665)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:288)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.toolsBlock(ModelInterpreter.groovy:544)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.toolsBlock(ModelInterpreter.groovy:543)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:276)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:443)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:442)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:275)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withCredentialsBlock(ModelInterpreter.groovy:481)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withCredentialsBlock(ModelInterpreter.groovy:480)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:274)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inDeclarativeAgent(ModelInterpreter.groovy:586)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inDeclarativeAgent(ModelInterpreter.groovy:585)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:272)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.stageInput(ModelInterpreter.groovy:356)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.stageInput(ModelInterpreter.groovy:355)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:261)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inWrappers(ModelInterpreter.groovy:618)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inWrappers(ModelInterpreter.groovy:617)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:259)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:443)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:442)
    at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:254)
    at ___cps.transform___(Native Method)
    at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)
    at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
    at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
    at jdk.internal.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
    at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
    at com.cloudbees.groovy.cps.Next.step(Next.java:83)
    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
    at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
    at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:402)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:314)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:278)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)
Finished: FAILURE

I confirmed the latest plugin is loaded. Again, I do not see any of the branch configurations settings you show in the readme in my job's configuration. There is no "Set build Name" check box, nor is there any "Update build name" section either. Is this expected?

I understand that the plugin is working for you (hence why the issue was closed) however, its not working for me. I assume I am using this plugin incorrectly, but I cant tell why based on the documentation (the README.md).

What am I missing here?

damianszczepanik commented 2 years ago

Based on the error it works for change triggered by Gerrit but not when you run it manually

davehouser1 commented 2 years ago

Based on the error it works for change triggered by Gerrit but not when you run it manually

Ok, I understand now that "Gerrit" is some plugin that the example in the README is using that I am not using. I figured it out on how to get the actual branch name to show, here is how I accomplished it in my pipeline.

However its still not clear to me why I cant see any of of the "Set build name" settings in my Jenkins Pipeline or Multibranch pipeline. Does a Jenkins job need to be built a specific way for these web settings to appear?

Thanks for the help.

pipeline {
agent {label 'node2'}
    options {
        ansiColor('xterm')
    }
    environment {
        CURRENT_BRANCH_NAME = "${GIT_BRANCH.split('/').size() > 1 ? GIT_BRANCH.split('/')[1..-1].join('/') : GIT_BRANCH}"
    }
    stages {
        stage('Set branch name') {
            steps {
                buildName "#${currentBuild.number}: $CURRENT_BRANCH_NAME"
                buildDescription "Executed @ ${NODE_NAME}"
            }
        }
    }
    post {
        always {
            script {
                currentBuild.result = currentBuild.result ?: 'SUCCESS'
                notifyBitbucket()
            }
        }
    }
}
damianszczepanik commented 2 years ago

Then this looks like problem with plugin or configuration - your code looks good enough to work

wheelhorse commented 1 year ago

@damianszczepanik, I did not put any of the pipline code in my Jenkinsfile. Its not clear if I needed to or not, is this a requirement? I thought I could just load the plugin and the "set build name" setting would show up in the job settings. Is this not the case?

highlight Looks like this is an only issue with Pipeline and Folder, I tried to use FreeStyleProject, the environment section shows up. So I think the author didn't add it to all kind of projects, maybe only for the FreeStyleProject. Not sure it's a bug or intended to do that. Highly appreciate if anyone could comment on this issue.

Same problem with you that cannot see the section with "set build name", have you gotten it fixed? I could also change the build name after the build start, but cannot set the build name to desired one when the build is still in the queue.

thanks!

Environment What Operating System are you using (both controller, and any agents involved in the problem)? Ubuntu 20.04 Running on Docker image jenkins/jenkins:latest Running version Jenkins 2.377

Reproduction steps Download the latest plugin from here , version 2.2.0 Installed the plugin manually. Went to my job, configure settings, I see no "set build name" section anywhere.

wheelhorse commented 1 year ago

@damianszczepanik

Then this looks like problem with plugin or configuration - your code looks good enough to work

Do this plugin support Pipeline project?