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

fix: prevent errors when using secure connections #19

Merged
merged 4 commits into from
Jan 13, 2025

Conversation

tapayne88
Copy link
Contributor

With my version of curl (v8.7.1), if I use a secure jenkins host I get the following error from the job.

This isn't surfaced very well as it the code errors when trying to decode the empty response

local args = vim.fn.json_decode(concatenated_crumbs)

Job reports the error when logged:

[jenkinsfile-linter]   _stderr_results = { "curl: option : blank argument where content is expected" },
...
[jenkinsfile-linter]   args = { "", "--user", "<username>:<token>", "https://<my-secure-jenkins>/crumbIssuer/api/json" },

This looks to be coming from the insecure parameter which defaults to an empty string when not set via the environment.

This PR should fix this scenario and report job failures more consistently

@tapayne88 tapayne88 force-pushed the fix/curl-empty-string branch from 51e108b to 19ebbd8 Compare December 27, 2024 15:59
end, tbl)
end

local function handle_error(msg)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like Job's on_stderr can surface errors from the coroutine as the first argument
https://github.com/nvim-lua/plenary.nvim/blob/2d9b06177a975543726ce5c73fca176cedbffe9d/lua/plenary/job.lua#L333

end
end

local function handle_job_error(job)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tapayne88 tapayne88 marked this pull request as ready for review December 27, 2024 17:00
@sampathpagolu
Copy link

I am seeing the same error on MacOS Sequoia, curl 8.9.1. Made some local changes to get it to work. Hoping to see this get merged.

Copy link
Owner

@ckipp01 ckipp01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't use Jenkins anymore, so it's quite hard to test this. This looks good, so I'll just go ahead and say LGTM. Thanks!

@ckipp01 ckipp01 merged commit 64d355e into ckipp01:main Jan 13, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants