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

jf does not consider quotes when splitting the args string #15

Open
getrostt opened this issue Mar 16, 2023 · 1 comment
Open

jf does not consider quotes when splitting the args string #15

getrostt opened this issue Mar 16, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@getrostt
Copy link

Describe the bug

The jf step does not consider quotes when splitting an args string.

The following command works on the shell:

jf rt curl -XPUT -H "Content-Type: application/json" --upload-file buildinfo.json "/api/build" --server-id=af

The equivalent in a Jenkins pipeline fails:

jf('rt curl -XPUT -H "Content-Type: application/json" --upload-file buildinfo.json "/api/build" --server-id=af')

Workaround: Pass a list of arguments:

jf(['rt', 'curl', '-XPUT', '-H', "Content-Type: application/json", '--upload-file', 'buildinfo.json', "/api/build", '--server-id=af'])

Current behavior

The following pipeline step results in an error:

jf('rt curl -XPUT -H "Content-Type: application/json" --upload-file buildinfo.json "/api/build" --server-id=af')

The console output:

10:55:08    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
10:55:08                                   Dload  Upload   Total   Spent    Left  Speed
10:55:09  
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   799  100   435  100   364   5958   4986 --:--:-- --:--:-- --:--:-- 10945
10:55:09  <!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1></body></html>  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
10:55:09                                   Dload  Upload   Total   Spent    Left  Speed
10:55:09  
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: "

Reproduction steps

see description

Expected behavior

The header parameter value Content-Type: application/json should be treated as one argument and not two.

JFrog plugin version

1.2.0

JFrog CLI version

2.34.6

Operating system type and version

Debian

JFrog Artifactory version

JFrog Cloud

JFrog Xray version

No response

@getrostt getrostt added the bug Something isn't working label Mar 16, 2023
@yahavi
Copy link
Collaborator

yahavi commented Mar 17, 2023

@getrostt,
This is actually the expected behavior - the plugin splits the arguments by whitespace and executes the JFrog CLI with these arguments. Using more sophisticated algorithms is risky and may not work in some cases (See jfrog#41 (comment)).
To support special cases such as quotes and spaces, since 1.2.0 we allow providing the arguments as a list.

For more information see step 2 under Using JFrog CLI in your pipeline jobs in the README.

Please let me know if that helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants