jenkinsci / zulip-plugin

Jenkins plugin for Zulip notifications of build status
https://zulip.com/integrations/doc/jenkins
MIT License
14 stars 22 forks source link

In a multi-configuration project with an agent axis, the default topic is the name of the agent, not the name of the project/job. #39

Closed epaul13 closed 1 year ago

epaul13 commented 1 year ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.387.3 OS: Linux - 5.15.104-1-pve Java: 11.0.18 - Ubuntu (OpenJDK 64-Bit Server VM) --- ansicolor:1.0.2 antisamy-markup-formatter:159.v25b_c67cd35fb_ apache-httpcomponents-client-4-api:4.5.14-150.v7a_b_9d17134a_5 bootstrap5-api:5.3.0-1 bouncycastle-api:2.28 build-timeout:1.31 caffeine-api:3.1.6-115.vb_8b_b_328e59d8 categorized-view:1.12 checks-api:2.0.0 claim:516.v36293563731d command-launcher:100.v2f6722292ee8 commons-lang3-api:3.12.0-36.vd97de6465d5b_ commons-text-api:1.10.0-36.vc008c8fcda_7b_ configuration-as-code:1647.ve39ca_b_829b_42 credentials:1254.vb_96f366e7b_a_d display-url-api:2.3.7 echarts-api:5.4.0-5 excludeMatrixParent:1.1 font-awesome-api:6.4.0-1 instance-identity:142.v04572ca_5b_265 ionicons-api:56.v1b_1c8c49374e jackson2-api:2.15.2-350.v0c2f3f8fc595 jakarta-activation-api:2.0.1-3 jakarta-mail-api:2.0.1-3 javax-activation-api:1.2.0-6 javax-mail-api:1.6.2-9 jaxb:2.3.8-1 jdk-tool:66.vd8fa_64ee91b_d jquery3-api:3.7.0-1 jsch:0.2.8-65.v052c39de79b_2 junit:1207.va_09d5100410f ldap:682.v7b_544c9d1512 mailer:457.v3f72cb_e015e5 matrix-auth:3.1.8 matrix-project:789.v57a_725b_63c79 mercurial:1260.vdfb_723cdcc81 mina-sshd-api-common:2.10.0-69.v28e3e36d18eb_ mina-sshd-api-core:2.10.0-69.v28e3e36d18eb_ nodelabelparameter:1.12.0 plugin-util-api:3.3.0 role-strategy:633.v836e5b_3e80a_5 scm-api:672.v64378a_b_20c60 script-security:1251.vfe552ed55f8d snakeyaml-api:1.33-95.va_b_a_e3e47b_fa_4 ssh-credentials:305.v8f4381501156 ssh-slaves:2.877.v365f5eb_a_b_eec sshd:3.303.vefc7119b_ec23 structs:324.va_f5d6774f3a_d timestamper:1.25 token-macro:359.vb_cde11682e0c trilead-api:2.84.v72119de229b_7 view-job-filters:364.v48a_33389553d workflow-api:1213.v646def1087f9 workflow-job:1308.v58d48a_763b_31 workflow-step-api:639.v6eca_cd8c04a_a_ workflow-support:839.v35e2736cfd5c zulip:2.0.0-SNAPSHOT (private-262aa562-epaul) ```

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

Ubuntu 22.04 for the controller. 4 agents on Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04 and RHEL8.

Reproduction steps

  1. create a multi-configuration project
  2. configure the zulip plugin
  3. Create a multi-configuration project with an agent axis
  4. build project

Expected Results

I expect a message with the topic containing the projet/job name.

Actual Results

I get the agent name in the message topic.

Anything else?

If I configure $JOB_NAME for the topic, I get job_name/Agent=agent_name, which is fine, but then I get a Project: agent_name link instead of Project: job_name. The link is correct but not the label.

butchyyyy commented 1 year ago

Thanks for reporting @epaul13

Am I correct to assume this is regression in version 2.0.0? If yes I think I know which change probably caused this. Either way it would be great to get some screen shots of the configuration and the messages you are getting in Zulip so that I can reproduce on my instance.

butchyyyy commented 1 year ago

Ok, so I have set up Matrix project called "multi" with agent X axis:

image

I have added the Zulip notifier step with empty topic:

image

I have disabled full job paths in the project configuration:

image

When I run the build, the notifications are posted into built-in and my-agent topics

image

There are no smarts around multi project configuration in the plugin, the default topic logic is to get the build's direct parent display name (unless you have the use full job path options on in which case it iterates / uses the whole parent chain). What would you imagine to be the correct topic name in such configured project?

Note for variables like $JOB_NAME: The plugin only expands variables in strings with values provided by Jenkins, it has no control over variable content.

epaul13 commented 1 year ago

Hi,

thank you for the fast answer.

Well, I'm perfectly fine with the message you get :)

What I get : jenkins_zulip

The first one is with $JOB_NAME configured in "topic name", the second with nothing configured for "topic name" in the main Jenkins configuration:

jenkins_zulip_conf

with multi:

jenkins_multi

As you see, I use $JOB_NAME to get my project info in the topic, which is fine. But Then the project in the message body is not good. If I don't use $JOB_NAME, the topic only shows the node and I only have the build in the body, which is not convenient to know which project failed ;)

As I said, I'm fine with what you get on your side :)

Tell me if you need more information.

Eric.

butchyyyy commented 1 year ago

Thanks for providing the details, the logic behind that is:

IUUC the problem in your case is that the <job_display_name> only includes build run direct parent which is the Jenkins agent in this case.

For this use case, the plugin has the Use full job path ... options.

Option with blank topic

If you use following configuration

image

\ Plugin will post into a multi » built-in topic, where multi is the matrix project name and built-in is the agent name \

image

Option with fixed topic

If you use following configuration

image

\ Plugin will post into fixedtopic, but the message will include full project name \

image

Does either of these options work for you?

epaul13 commented 1 year ago

I get the logic, fine for me.

If I use one of the "Use full job path" options, I get the information, fine too:

image

My point was that without configuring anything, the "parsing" of a "full job name" leads to display the agent name and not the job name in the topic, and I get no info on which project failed. I can get the information either by using the fixed topic "$JOB_NAME" (but then the body of the message display the agent name not the project name) or by configuring one of the "Use full job path" options. That's fine for me, I get my information.

For the record, I'll use:

image

This way I get the info in the topic and I can click the build number to go to the failed build.

Nevertheless, I think this might be considered a "bug" or an inconvenience. That's why I decided to report. :)

By the way, looking at your previous answer, it seems that you don't have the same behavior as me? IIUC, you get the correct info without checking any of the "Use full job path" options, right?

In any case, I get what I need, you have a useful plugin and do a great support, thank you again!

Eric.

butchyyyy commented 1 year ago

By the way, looking at your previous answer, it seems that you don't have the same behavior as me? IIUC, you get the correct info without checking any of the "Use full job path" options, right?

Nope, it behaves same as for you, e.g. with blank topic I get just the agent name and build number and no project info:

image

My point was that without configuring anything, the "parsing" of a "full job name" leads to display the agent name and not the job name in the topic, and I get no info on which project failed.

Fair point, actually your report is the same as #31, just for matrix project instead of multi branch pipeline. Based on this the full job path options were introduced.

I think that the conclusion of this ticket are two action items for me:

epaul13 commented 1 year ago

Seems like a good move. It's a pity there's no clear pattern or var to get the job's name. Extracting it depending on project's type through retro-engineering seems overkill ;-) Thanks again for the support!

butchyyyy commented 1 year ago

Readme adjusted in d4b9acf3fd619c2c173f602aaabdc7083b037b8e Full job paths and smart notify enabled by default for new installations in df49757f93c65a483842b9f18f2f1eef70832f02