-
Notifications
You must be signed in to change notification settings - Fork 414
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
Comments
Confirmed same results. |
Can you show it showing up in your Slack? The log reports it uploading but Slack doesn't appear to receive it. |
The first screenshot has that, because its a text file it gets expanded |
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. |
I don't think it is. |
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. |
Yes they are two separate calls. You can enable http logging:
see more details at https://hc.apache.org/httpcomponents-client-4.5.x/logging.html
For file upload a custom bot user is required. |
Can you add a log recorder like here but for org.apache.http please: |
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 |
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. |
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. |
I've had a look at the logs and I can't see anything wrong there. A few things to try:
|
I've also reviewed it. The logs aren't indicating a problem.
No.
Generally yes, but a custom slack bot is sending them in the case of a freestyle job.
My concern is that the file is uploaded, but without channel_id. According to the documentation you posted:
While it should default to the channel attached to the slackbot, I wonder if this might be getting broken somehow. |
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. |
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. |
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... |
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 |
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. |
Here is my app manifest:
|
I am also using a custom Slack app bot user. Maybe this is the difference causing issues. |
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:
Same result, no file:
|
Just tried again not specifying the workspace and got the same result. |
Just tried again also removing custom slack bot user and got the same result. |
I'm now duplicating all of your settings, with the same result:
No file appears on Slack. |
Can you try this debug build with extra logging? #1003 The http logging isn't too useful from before as it doesn't include requests and responses. Hopefully this helps |
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:
|
I built it myself, so I'll re-install with your finished file. |
Result:
|
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) |
🤦 Ok let me find this log. |
Got it: (Note I only changed some IDs and names, if it's blank, it's blank)
|
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 |
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.
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 will try to grab the additional logging if it's posted this morning. |
New build is: https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/slack/740.v90d8ddedfffd/slack-740.v90d8ddedfffd.hpi Try without the |
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.
|
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). |
K in pipeline I'm pretty sure thats handled but it mustn't quite go down the same code path for freestyle. |
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. |
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! |
Jenkins and plugins versions report
Environment
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
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:
I setup logging for StandardSlackServices and see the following:
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.
The text was updated successfully, but these errors were encountered: