jenkinsci / jenkinsci/file-parameters-plugin

allowNoFile attribute for withFileParameter step does not have the expected behavior

Open
#166 0 comments 2 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
15
Forks
16
PR merge metrics
No merged PRs in 30d

Description

### Jenkins and plugins versions report

Environment

```text
Jenkins: 2.387.2
OS: Linux - 5.4.0-146-generic
Java: 11.0.11 - AdoptOpenJDK (OpenJDK 64-Bit Server VM)
file-parameters:285.v757c5b_67a_c25
```

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

Ubuntu 20.04 and Windows 10 VMs

### Reproduction steps

Scripted pipeline definition:
```groovy
properties([
parameters([
base64File(name: 'myFile')
])
])

node {
deleteDir()
stage('test') {
withFileParameter(name: 'myFile', allowNoFile: false) {
echo readFile(file: myFile)
}
}
}
```

### Expected Results

When a build is started without providing a file to the 'myFile' Job parameter, I expect the build to fail since the `allowNoFile` attribute is set to `false`.

### Actual Results

The build does not fail when no file is given as a Job parameter, even though the `allowNoFile` argument is set to `false`.
However, the build fails if no parameters are declared in the Job configuration. This isn't absurd, but it's not what you'd expect from the `allowNoFile` argument. After all, the argument isn't called allowNoParameter.

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.