Hello Community!
Faced a potential Bug where using a Named Parameter with name shared by a Unix command (I’ve faced it with unzip) fails the actual ‘unzip’ command with weird outputs. (Clueless to why the behavior is such).
Since i’m new here, im also unaware on the procedure to Submit a Bug, thus welcoming you to this topic.
This was rather easy to replicate, and occurs each time.
Example:
Expected error when zip file is not present
Here the file is present, and the error is that parameter value is being taken as filename (First argument to unzip is interchanged with UNZIP’s parameter value)
Script:
properties([
parameters([
string(defaultValue: 'thisisbreaking',
description: 'Test Paramter',
name: 'UNZIP', trim: true)
])
])
node('agent_name') {
dir('/tmp/folder') {
sh 'unzip thisisazipfile.zip'
}
}
Output:
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Node in workspace path
[Pipeline] {
[Pipeline] dir
Running in /tmp/folder
[Pipeline] {
[Pipeline] sh
ls -la
total 348
drwxrwxrwx 2 user user 4096 Jan 16 16:27 .
drwxrwxrwt 23 root root 344064 Jan 16 16:30 …
-rw-rw-r-- 1 user user 172 Jan 16 16:10 thisisazipfile.zip
unzip thisisazipfile.zip
unzip: cannot find or open thisisbreaking, thisisbreaking.zip or thisisbreaking.ZIP.
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 9
Finished: FAILURE
Any help or direction to raise this as a Bug would be welcome
Temporary fix is to not use ‘UNZIP’ as a parameter name.