Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Attachments No Longer Work for Freestyle Jobs #993

Closed
MichaelPhillipsPS opened this issue Aug 6, 2024 · 45 comments
Closed

File Attachments No Longer Work for Freestyle Jobs #993

MichaelPhillipsPS opened this issue Aug 6, 2024 · 45 comments
Labels

Comments

@MichaelPhillipsPS
Copy link

Jenkins and plugins versions report

Environment
Jenkins: 2.452.3
OS: Windows Server 2016 - 10.0
Java: 21.0.2 - Oracle Corporation (Java HotSpot(TM) 64-Bit Server VM)
---
ansicolor:1.0.4
antisamy-markup-formatter:162.v0e6ec0fcfcf6
apache-httpcomponents-client-4-api:4.5.14-208.v438351942757
asm-api:9.7-33.v4d23ef79fcc8
audit-trail:361.v82cde86c784e
authentication-tokens:1.119.v50285141b_7e1
azure-ad:507.vea_a_a_167b_d05c
azure-sdk:174.va_89c1df897d2
bootstrap5-api:5.3.3-1
bouncycastle-api:2.30.1.78.1-248.ve27176eb_46cb_
branch-api:2.1178.v969d9eb_c728e
build-name-setter:2.4.3
build-timeout:1.33
caffeine-api:3.1.8-133.v17b_1ff2e0599
checks-api:2.2.0
cloudbees-bitbucket-branch-source:888.v8e6d479a_1730
cloudbees-folder:6.928.v7c780211d66e
command-launcher:107.v773860566e2e
commons-lang3-api:3.14.0-76.vda_5591261cfe
commons-text-api:1.12.0-129.v99a_50df237f7
conditional-buildstep:1.4.3
credentials:1371.vfee6b_095f0a_3
credentials-binding:681.vf91669a_32e45
custom-view-tabs:1.3
dark-theme:439.vdef09f81f85e
dashboard-view:2.508.va_74654f026d1
data-tables-api:2.0.8-1
design-library:303.v6b_23c12334c9
display-url-api:2.204.vf6fddd8a_8b_e9
durable-task:555.v6802fe0f0b_82
echarts-api:5.5.0-1
eddsa-api:0.3.0-4.v84c6f0f4969e
email-ext:1814.v404722f34263
envinject:2.919.v009a_a_1067cd0
envinject-api:1.199.v3ce31253ed13
favorite:2.218.vd60382506538
font-awesome-api:6.5.2-1
generic-webhook-trigger:2.2.2
git:5.3.0
git-client:5.0.0
git-server:126.v0d945d8d2b_39
github:1.39.0
github-api:1.321-468.v6a_9f5f2d5a_7e
github-branch-source:1793.v1831e9c68d77
gitlab-plugin:1.8.1
gson-api:2.11.0-41.v019fcf6125dc
handy-uri-templates-2-api:2.1.8-30.v7e777411b_148
htmlpublisher:1.36
instance-identity:185.v303dc7c645f9
ionicons-api:74.v93d5eb_813d5f
jackson2-api:2.17.0-379.v02de8ec9f64c
jakarta-activation-api:2.1.3-1
jakarta-mail-api:2.1.3-1
javadoc:243.vb_b_503b_b_45537
javax-activation-api:1.2.0-7
javax-mail-api:1.6.2-10
jaxb:2.3.9-1
jdk-tool:73.vddf737284550
jersey2-api:2.42-147.va_28a_44603b_d5
jjwt-api:0.11.5-112.ve82dfb_224b_a_d
jnr-posix-api:3.1.19-2
jobConfigHistory:1229.v3039470161a_d
joda-time-api:2.12.7-29.v5a_b_e3a_82269a_
jquery3-api:3.7.1-2
jsch:0.2.16-86.v42e010d9484b_
json-api:20240303-41.v94e11e6de726
json-path-api:2.9.0-58.v62e3e85b_a_655
junit:1280.v310a_78b_9a_1e0
lockable-resources:1255.vf48745da_35d0
mailer:472.vf7c289a_4b_420
material-theme:0.5.2-rc100.6121925fe229
matrix-auth:3.2.2
matrix-project:832.va_66e270d2946
maven-plugin:3.23
mina-sshd-api-common:2.13.1-117.v2f1a_b_66ff91d
mina-sshd-api-core:2.13.1-117.v2f1a_b_66ff91d
nested-view:1.34
okhttp-api:4.11.0-172.vda_da_1feeb_c6e
pam-auth:1.11
parameterized-trigger:806.vf6fff3e28c3e
pipeline-build-step:540.vb_e8849e1a_b_d8
pipeline-graph-analysis:216.vfd8b_ece330ca_
pipeline-groovy-lib:727.ve832a_9244dfa_
pipeline-input-step:495.ve9c153f6067b_
pipeline-milestone-step:119.vdfdc43fc3b_9a_
pipeline-model-api:2.2205.vc9522a_9d5711
pipeline-model-definition:2.2205.vc9522a_9d5711
pipeline-model-extensions:2.2205.vc9522a_9d5711
pipeline-rest-api:2.34
pipeline-stage-step:312.v8cd10304c27a_
pipeline-stage-tags-metadata:2.2205.vc9522a_9d5711
pipeline-stage-view:2.34
plain-credentials:183.va_de8f1dd5a_2b_
plugin-util-api:4.1.0
powershell:2.1
prism-api:1.29.0-15
pubsub-light:1.18
purge-build-queue-plugin:88.v23b_97b_f2c7a_d
purge-job-history:1.6
rebuild:332.va_1ee476d8f6d
resource-disposer:0.23
run-condition:1.7
scm-api:696.v778d637b_a_762
script-security:1341.va_2819b_414686
shiningpanda:0.24
simple-theme-plugin:191.vcd207ef9dd24
slack:722.vd07f1ea_7ff40
snakeyaml-api:2.2-111.vc6598e30cc65
sse-gateway:1.27
ssh-credentials:343.v884f71d78167
sshd:3.330.vc866a_8389b_58
structs:338.v848422169819
theme-manager:262.vc57ee4a_eda_5d
timestamper:1.27
token-macro:400.v35420b_922dcb_
trilead-api:2.147.vb_73cc728a_32e
variant:60.v7290fc0eb_b_cd
workflow-aggregator:600.vb_57cdd26fdd7
workflow-api:1322.v857eeeea_9902
workflow-basic-steps:1058.vcb_fc1e3a_21a_9
workflow-cps:3922.va_f73b_7c4246b_
workflow-durable-task-step:1364.v2fd76fb_6fd41
workflow-job:1400.v7fd111b_ec82f
workflow-multibranch:783.787.v50539468395f
workflow-scm-step:427.v4ca_6512e7df1
workflow-step-api:678.v3ee58b_469476
workflow-support:920.v59f71ce16f04
ws-cleanup:0.46

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

Jenkins server is running Windows Server 2016 Datacenter.

Reproduction steps

  1. Setup a Jenkins freestyle job using a Slack notification post-build action.
  2. Specify a file to be uploaded.
  3. Watch as the message sends but no file is attached.

This issue seems to happen on newer builds; older versions of the plugin seem to work (6.84 works) without issue. I did update the scopes of our bot users to reflect the new scope requirements referenced in the 7.11 release.

I have verified the the file is found. I see the following in the console output of the job:

Using dirname=C:\Users\<username>\AppData\Local\Jenkins\.jenkins\workspace\Test-WebhookURL and includeMask=beepboop.txt
Adding file C:\Users\<username>\AppData\Local\Jenkins\.jenkins\workspace\Test-WebhookURL\beepboop.txt

I setup logging for StandardSlackServices and see the following:

Aug 06, 2024 10:58:30 AM FINE jenkins.plugins.slack.StandardSlackService

Posting: to C03M0NU3GN9 on PowerSchool:  {"attachments":[{"fallback":"Test-WebhookURL - #74 Success after 1.1 sec (<https://itjenkins.powerschool.com/job/Test-WebhookURL/74/display/redirect|Open>)","color":"good","fields":[{"short":false,"value":"Test-WebhookURL - #74 Success after 1.1 sec (<https://itjenkins.powerschool.com/job/Test-WebhookURL/74/display/redirect|Open>)"}],"mrkdwn_in":["pretext","text","fields"]}],"link_names":"1","unfurl_links":"true","unfurl_media":"true","channel":"<channelID>","username":"Jenkins Notifications"}

Aug 06, 2024 10:58:30 AM FINE jenkins.plugins.slack.StandardSlackService

Posting succeeded

As far as I can tell, no attempt is even being made to send the file. I see no reference to it in the log information at all.

Expected Results

The message should be posted with a file attachment. It works with 6.84, and maybe other legacy versions, of the plug-in.

Actual Results

The message sends, but without file attachments.

Anything else?

I did also test this on an instance of Jenkins installed on my local machine with the same result.

Are you interested in contributing a fix?

If there's some way I could contribute, I would be happy to do it, though I'm not sure I would be much use.

@jayadelson
Copy link

Confirmed same results.

@timja
Copy link
Member

timja commented Aug 24, 2024

Works just fine for me:

image image image image

@jayadelson
Copy link

Can you show it showing up in your Slack? The log reports it uploading but Slack doesn't appear to receive it.

@timja
Copy link
Member

timja commented Aug 24, 2024

The first screenshot has that, because its a text file it gets expanded

@MichaelPhillipsPS
Copy link
Author

Works just fine for me:
image image image image

Okay, so in the jobs I'm running I don't have the "Archive Artifacts" post build action. Is that required? Does the file still upload for you if you remove that step? If so, then it previously was not required, as the plug-in uploads the files without that step the way jobs are currently setup on our server (I rolled back the plug-in to an older version for now). If that's all it is, then great.

@timja
Copy link
Member

timja commented Aug 26, 2024

I don't think it is.

@MichaelPhillipsPS
Copy link
Author

Okay, got it. My guess is, then, that there's an issue with the call being used to attach the file to the message. I don't actually know what's happening under the hood, but I'm assuming the message is posted, and then the file is attached to it in a separate call, and that's what is failing. If it was a single call, then I imagine the message would just fail to post entirely.

Are you using a custom Slack bot user to post the message? I tried remaking the Slack bot user, and it didn't work with the newly created account either, but maybe the message needs to be sent a different way.

@timja
Copy link
Member

timja commented Aug 26, 2024

Yes they are two separate calls.

You can enable http logging:

org.apache.http

see more details at https://hc.apache.org/httpcomponents-client-4.5.x/logging.html

Are you using a custom Slack bot user to post the message

For file upload a custom bot user is required.

@jayadelson
Copy link

I have my settings the same as they were when it used to work prior to about May of this year.

This is the job's configuration:
slack_upload

This is the job's log output:
slack_upload_log

I'm honestly not sure what else I should be doing here. I've tried putting this into the pipeline script, it still doesn't work.

@timja
Copy link
Member

timja commented Aug 26, 2024

Can you add a log recorder like here but for org.apache.http please:
https://github.com/jenkinsci/slack-plugin#enable-additional-logging

@MichaelPhillipsPS
Copy link
Author

From what I can tell, it's making the first call to get the uploadURL from Slack:
image

It then appears to be making the follow up call, though I'm not well versed on how to read these logs. It indicates it was successful, and, as mentioned, the message sends, there's just no attachment. Here's what I see though (let me know if I'm leaving out something relevant):
image

@timja
Copy link
Member

timja commented Aug 26, 2024

I can't see the response which is probably further down.

Adding as text would be easier to read and just replace anything with redacted if you don't want it included

@MichaelPhillipsPS
Copy link
Author

Every response seemed to be a 200 response when I looked. I'll see if I can grab more details. The log is quite verbose. Also, I'm sure I redacted more than is really necessary (like the uploadURL), but I was just playing it safe.

@MichaelPhillipsPS
Copy link
Author

Here is the full logging output, aside from the bearer token being redacted. I setup a Jenkins server on my local system to test and had the same issue, so this is from that. It experiences the same issue though, and the logs look largely the same. Thanks so much for your help.

jenkins_httplog_slackplugin.txt

@timja
Copy link
Member

timja commented Aug 27, 2024

I've had a look at the logs and I can't see anything wrong there.

A few things to try:

  1. Does it work in a pipeline for you?
  2. Can you complete the API requests via curl yourself and does it work? - https://api.slack.com/messaging/files#uploading_files
  3. Email feedback@slack.com to raise a support request and see if they can help you

@jayadelson
Copy link

I've had a look at the logs and I can't see anything wrong there.

I've also reviewed it. The logs aren't indicating a problem.

  1. Does it work in a pipeline for you?

No.

  1. Can you complete the API requests via curl yourself and does it work? - https://api.slack.com/messaging/files#uploading_files

Generally yes, but a custom slack bot is sending them in the case of a freestyle job.

  1. Email feedback@slack.com to raise a support request and see if they can help you

My concern is that the file is uploaded, but without channel_id. According to the documentation you posted:

Here's a potentially confusing bit when you use the channel_id parameter during your upload: supplying channel_id will "share" the file to a channel. If you don't use the channel_id parameter, this only "uploads" the file — hosting the file in Slack — but doesn't "share" the file anywhere. Crucially, only the uploader will have access to the file if it is not shared anywhere.

While it should default to the channel attached to the slackbot, I wonder if this might be getting broken somehow.

@MichaelPhillipsPS
Copy link
Author

I am realizing I don't see channel_id or thread_ts anywhere in that output. This makes me think the file might be getting uploaded, but isn't being attached to the message properly. This is the documentation from Slack on that last call it's making, where they indicate those two optional values as parameters:

https://api.slack.com/methods/files.completeUploadExternal

Also, I was able to send a call in Postman successfully, though I don't see it in the channel either, even when explicitly passing the channel ID. In terms of a pipeline job, I would have to figure that out. We don't use those, and I've never set one up. If I get the chance, I'll try to figure out setting up a job to use the Slack plugin via pipeline.

@jayadelson
Copy link

I should also add I've made all the recommended adjustments to scope, granted all required permissions, and tested this on different implementations of both pipeline and freestyle without success for a 50MB file. This started happening with the plugin update in May, so I'm not saying it's correlated, but just for context.

@timja
Copy link
Member

timja commented Aug 27, 2024

Assuming you mean the one with scope changes it will be related as Slack deprecated the old method and isn't allowing new apps to use the old method...

@timja
Copy link
Member

timja commented Aug 27, 2024

I tried with a 50mb file and no artifact archiving:

image image image

I have no channel overrides or anything just my global config

@timja
Copy link
Member

timja commented Aug 27, 2024

This is my Slack app manifest:

display_information:
  name: Jenkins
features:
  bot_user:
    display_name: Jenkins
    always_online: true
oauth_config:
  scopes:
    bot:
      - channels:read
      - chat:write
      - chat:write.customize
      - files:write
      - reactions:write
      - users:read
      - users:read.email
      - groups:read
settings:
  org_deploy_enabled: false
  socket_mode_enabled: false
  token_rotation_enabled: false

@jayadelson
Copy link

Assuming you mean the one with scope changes it will be related as Slack deprecated the old method and isn't allowing new apps to use the old method...

Correct. I noticed you have custom slack app bot user unchecked. This is required. Can you try with that? We're not sending this to a DM or via a @slackbot source.

@jayadelson
Copy link

jayadelson commented Aug 27, 2024

Here is my app manifest:

display_information:
  name: BotName
  description: Jenkins Buildbot
  background_color: "#0d9788"
features:
  bot_user:
    display_name: BotName
    always_online: false
oauth_config:
  scopes:
    user:
      - files:read
      - files:write
      - remote_files:read
      - remote_files:share
    bot:
      - channels:read
      - chat:write
      - chat:write.customize
      - chat:write.public
      - files:write
      - reactions:write
      - groups:read
      - files:read
      - groups:write
      - remote_files:read
      - remote_files:share
      - remote_files:write
settings:
  org_deploy_enabled: false
  socket_mode_enabled: false
  token_rotation_enabled: false

@MichaelPhillipsPS
Copy link
Author

I am also using a custom Slack app bot user. Maybe this is the difference causing issues.

@jayadelson
Copy link

jayadelson commented Aug 27, 2024

I just tried it with @timja 's exact settings in the manifest, reinstalled app in the workspace, no artifact archiving. I also test connection and it's successful before executing the job.

Three differences are:

  • I'm using Credential set up for slack
  • I'm using custom slack bot user.
  • I specify the workspace

Same result, no file:

+ cp android/app/build/outputs/apk/debug/app-debug.apk android/app/build/outputs/apk/debug/xxxxxx_1302.apk
[Slack Notifications] found #1301 as previous completed, non-aborted build
[Slack Notifications] will send OnSuccessNotification because build matches and user preferences allow it
Using dirname=/Users/yyyyy/jenkins/workspace/yyyyy_Android_Staging and includeMask=android/app/build/outputs/apk/debug/xxxxxx*
Adding file /Users/yyyyy/jenkins/workspace/yyyyy_Android_Staging/android/app/build/outputs/apk/debug/xxxxxx_1302.apk
Finished: SUCCESS

@jayadelson
Copy link

Just tried again not specifying the workspace and got the same result.

@jayadelson
Copy link

Just tried again also removing custom slack bot user and got the same result.

@timja
Copy link
Member

timja commented Aug 27, 2024

I do have custom slack app bot user ticked on my global config:
image

@jayadelson
Copy link

I'm now duplicating all of your settings, with the same result:

  • No worspace in job configuration
  • No credential in job configuration
  • No channel in job configuration
  • No custom slack app bot user checked in job configuration
  • System/global config contains the same as yours above
  • Test Connection results in a "you're all set" message on Slack.
  • Uploading file reports no issue

No file appears on Slack.

@timja
Copy link
Member

timja commented Aug 27, 2024

Can you try this debug build with extra logging? #1003
(https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/slack/739.v94cd5f63a_30b_/slack-739.v94cd5f63a_30b_.hpi)

The http logging isn't too useful from before as it doesn't include requests and responses. Hopefully this helps

@jayadelson
Copy link

jayadelson commented Aug 27, 2024

Ok, I built and installed your build. I'm not entirely sure I'm looking at the right log, but this is what I got:

Aug 27, 2024 6:08:35 PM INFO jenkins.plugins.slack.logging.SlackNotificationsLogger info
[XXXXX_Android_Staging #1306] found #1305 as previous completed, non-aborted build
Aug 27, 2024 6:08:35 PM INFO jenkins.plugins.slack.logging.SlackNotificationsLogger info
[XXXXX_Android_Staging #1306] will send OnSuccessNotification because build matches and user preferences allow it
Aug 27, 2024 6:08:38 PM WARNING org.jenkinsci.plugins.workflow.cps.CpsStepContext$2 onFailure
Failed to proceed after CpsStepContext[29:build]:Owner[XXXXX_App/1288:XXXXX_App #1288]
java.lang.IllegalStateException: completed or broken execution
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.onLoad(CpsFlowExecution.java:850)
	at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun.getExecution(WorkflowRun.java:719)
	at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner.get(WorkflowRun.java:992)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsStepContext.getExecution(CpsStepContext.java:217)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsStepContext.getNode(CpsStepContext.java:302)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsStepContext.scheduleNextRun(CpsStepContext.java:368)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsStepContext.completed(CpsStepContext.java:326)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsStepContext.onFailure(CpsStepContext.java:314)
	at PluginClassLoader for pipeline-build-step//org.jenkinsci.plugins.workflow.support.steps.build.BuildTriggerListener.lambda$onDeleted$1(BuildTriggerListener.java:86)
	at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:67)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)

@jayadelson
Copy link

I built it myself, so I'll re-install with your finished file.

@jayadelson
Copy link

Result:

Aug 27, 2024 6:18:44 PM INFO jenkins.plugins.slack.logging.SlackNotificationsLogger info
[XXXXX_Android_Staging #1307] found #1306 as previous completed, non-aborted build
Aug 27, 2024 6:18:44 PM INFO jenkins.plugins.slack.logging.SlackNotificationsLogger info
[XXXXX_Android_Staging #1307] will send OnSuccessNotification because build matches and user preferences allow it
Aug 27, 2024 6:18:48 PM WARNING org.jenkinsci.plugins.workflow.cps.CpsStepContext$2 onFailure
Failed to proceed after CpsStepContext[29:build]:Owner[XXXXX_App/1291:XXXXX_App #1291]
java.lang.IllegalStateException: completed or broken execution
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.onLoad(CpsFlowExecution.java:850)
	at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun.getExecution(WorkflowRun.java:719)
	at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner.get(WorkflowRun.java:992)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsStepContext.getExecution(CpsStepContext.java:217)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsStepContext.getNode(CpsStepContext.java:302)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsStepContext.scheduleNextRun(CpsStepContext.java:368)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsStepContext.completed(CpsStepContext.java:326)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsStepContext.onFailure(CpsStepContext.java:314)
	at PluginClassLoader for pipeline-build-step//org.jenkinsci.plugins.workflow.support.steps.build.BuildTriggerListener.lambda$onDeleted$1(BuildTriggerListener.java:86)
	at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:67)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)

@timja
Copy link
Member

timja commented Aug 27, 2024

Are you building on an agent? If so the log will be in the agents log file.

(I just verified that freestyle on an agent works fine)

@jayadelson
Copy link

🤦 Ok let me find this log.

@jayadelson
Copy link

jayadelson commented Aug 27, 2024

Got it: (Note I only changed some IDs and names, if it's blank, it's blank)

Aug 27, 2024 6:14:31 PM hudson.remoting.Launcher$CuiListener status
INFO: Connected
Aug 27, 2024 6:18:47 PM jenkins.plugins.slack.pipeline.SlackUploadFileRunner completeUploadExternal
INFO: Completing upload with: {"files":[{"id":"ABCDEFGHIJK"}]}
Aug 27, 2024 6:18:47 PM jenkins.plugins.slack.pipeline.SlackUploadFileRunner completeUploadExternal
INFO: Upload complete response: {"files":[{"filetype":"","title":"xxxxx_staging_1307.apk","file_access":"visible","ims":[],"mode":"hosted","shares":{},"media_display_type":"unknown","url_private":"https://files.slack.com/files-pri/YYYYYYYYYY-ABCDEFGHIJK/xxxxx_staging_1307.apk","id":"ABCDEFGHIJK","display_as_bot":false,"timestamp":1724797126,"created":1724797126,"editable":false,"has_more_shares":false,"is_external":false,"groups":[],"pretty_type":"","external_type":"","url_private_download":"https://files.slack.com/files-pri/YYYYYYYYYY-ABCDEFGHIJK/download/xxxxx_staging_1307.apk","user_team":"YYYYYYYYYY","permalink_public":"https://slack-files.com/YYYYYYYYYY-ABCDEFGHIJK-a26583d641","has_rich_preview":false,"is_starred":false,"size":56691739,"channels":[],"comments_count":0,"name":"xxxxx_staging_1307.apk","is_public":false,"mimetype":"","public_url_shared":false,"permalink":"https://xxxxxxxxxx.slack.com/files/U02A56E7DTK/ABCDEFGHIJK/xxxxx_staging_1307.apk","user":"U02A56E7DTK","username":""}],"ok":true}

@timja
Copy link
Member

timja commented Aug 28, 2024

Completing upload with should always have a channel_id maybe it gets omitted for a null channel.

What's configured in your channel? you can change the words but not the format.

Also try with a channel ID instead of a channel name maybe.


I've pushed more debug logging which should help us tell whats going on in the channel ID lookup

@jayadelson
Copy link

What's configured in your channel? you can change the words but not the format.

Do you mean configured as the channel? At the time of that log, I duplicated your settings by having the freestyle job be blank and the global settings be a string (#app). Test connection worked in both places prior to running the job.

Also try with a channel ID instead of a channel name maybe.

I have tried putting a channel id (like 123455 or "123455") in the freestyle field without success. It seems to fail the test connection. I have not tried that in system settings yet.

I've pushed more debug logging which should help us tell whats going on in the channel ID lookup

I will try to grab the additional logging if it's posted this morning.

@timja
Copy link
Member

timja commented Aug 28, 2024

@jayadelson
Copy link

jayadelson commented Aug 28, 2024

EDIT: This worked, removing the # sign.

Here's the output with just the word:

app

in the channel field in system/global settings. Nothing in the field value in the job configuration. Test connection says successful.

Aug 28, 2024 10:50:14 AM jenkins.plugins.slack.pipeline.SlackUploadFileRunner completeUploadExternal
INFO: Completing upload with: {"files":[{"id":"FILE_ID"}],"channel_id":"C6GF1JV3J"}
Aug 28, 2024 10:50:14 AM jenkins.plugins.slack.pipeline.SlackUploadFileRunner completeUploadExternal
INFO: Upload complete response: {"files":[{"filetype":"","title":"xxxxx_staging_1308.apk","file_access":"visible","ims":[],"mode":"hosted","shares":{},"media_display_type":"unknown","url_private":"https://files.slack.com/files-pri/TEAM_ID-FILE_ID/xxxxx_staging_1308.apk","id":"FILE_ID","display_as_bot":false,"timestamp":1724856613,"created":1724856613,"editable":false,"has_more_shares":false,"is_external":false,"groups":[],"pretty_type":"","external_type":"","url_private_download":"https://files.slack.com/files-pri/TEAM_ID-FILE_ID/download/xxxxx_staging_1308.apk","user_team":"TEAM_ID","permalink_public":"https://slack-files.com/TEAM_ID-FILE_ID-029eed87fb","has_rich_preview":false,"is_starred":false,"size":56691772,"channels":[],"comments_count":0,"name":"xxxxx_staging_1308.apk","is_public":false,"mimetype":"","public_url_shared":false,"permalink":"https://spinnersystems.slack.com/files/USER_ID/FILE_ID/xxxxx_staging_1308.apk","user":"USER_ID","username":""}],"ok":true}

@jayadelson
Copy link

So in conclusion:

Putting the # in front of your channel (presumably anywhere, global or job) creates a problem where uploadFile will use a null channel. Per Slack documentation, this is a successful upload that no one (but the bot user) can see.

What I haven't tested is any differences between freestyle jobs and global settings, and also what the use of a channel ID does (with or without quotes).

@timja
Copy link
Member

timja commented Aug 28, 2024

K in pipeline I'm pretty sure thats handled but it mustn't quite go down the same code path for freestyle.

@timja
Copy link
Member

timja commented Aug 29, 2024

You both able to check if this resolves the issue for you: https://github.com/jenkinsci/slack-plugin/releases/tag/741.v00f9591c586d

@jayadelson
Copy link

jayadelson commented Aug 29, 2024

You both able to check if this resolves the issue for you: https://github.com/jenkinsci/slack-plugin/releases/tag/741.v00f9591c586d

I can confirm that the fix resolves this issue. Thank you, @timja for your help to resolve this so quickly.

@timja timja closed this as completed Aug 29, 2024
@MichaelPhillipsPS
Copy link
Author

Thanks for your help. It also seemed to resolve the issue for me, though it won't accept a channel ID value. When I tested with the channel name, it did indeed work. Super awesome work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants