forcedotcom / forcedotcom/cli

force:apex:test:run in JWT context seems to rely on the jwtkeyfile always being present

Open
#81 50 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
No language data
Stars
571
Forks
80
Avg merge
2d 15h
Merged PRs (30d)
3

Description

### Summary

force:apex:test:run command fails when using JWT connection and the jwtkeyfile file is missing from project folder

### Steps To Reproduce:

- Have jwtKeyFile at project root
- Authenticate to Dev Hub via JWT auth and make it defaultDevHub at least within the context of current SFDX project.
- Execute a scratch org creation
- `force:org:create --definitionfile config/project-scratch-def.json --json --setdefaultusername --durationdays 1`
- Push of source code
- `force:source:push --json`
- executes correctly
- Conduct an Apex Test run
- `force:apex:test:run --testlevel RunLocalTests --outputdir target --resultformat tap --json`
- executes correctly
- remove jwtKeyFile from project directory
- Push of source code
- `force:source:push --json`
- executes correctly
- Conduct an Apex Test run
- `force:apex:test:run --testlevel RunLocalTests --outputdir target --resultformat tap --json`
- **execution fails**

### Expected result

Execution of `force:apex:test:run` should succeed regardless of the presence of the jwtKeyFile

### Actual result

Execution of `force:apex:test:run` fails if jwtKeyFile is not present in project directory.

### Additional information

This becomes a blocker in Jenkins CI processes on SFDX projects. The recommended way to [manage the jwtKeyFile on Jenkins](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ci_jenkins_config_env.htm) is store it in the "Jenkins Admin Credentials interface." During build job execution, Jenkins will checkout all code to the build job's "workspace" folder. It will download the the jetKeyFile and other secret files to the adjacent folder "workspace@tmp" and inject that file during commands that explicitly utilize it (like the `force:auth:jwt:grant` command).

As it stands now, I am unable to utilize `force:apex:test:run` as part of my CI process.

**SFDX CLI Version**(to find the version of the CLI engine run sfdx --version):
- sfdx-cli/7.4.0-99233fd3af darwin-x64 node-v10.15.3

**SFDX plugin Version**(to find the version of the CLI plugin run sfdx plugins --core)
- @oclif/plugin-commands 1.2.2 (core)
- @oclif/plugin-help 2.1.6 (core)
- @oclif/plugin-not-found 1.2.2 (core)
- @oclif/plugin-plugins 1.7.8 (core)
- @oclif/plugin-update 1.3.9 (core)
- @oclif/plugin-warn-if-update-available 1.7.0 (core)
- @oclif/plugin-which 1.0.3 (core)
- @salesforce/sfdx-trust 3.0.2 (core)
- analytics 1.1.2 (core)
- generator 1.1.0 (core)
- salesforcedx 45.11.0 (core)
- force-language-services 45.10.0 (core)
- salesforce-alm 45.14.0 (core)
- sfdx-cli 7.4.0 (core)

**OS and version**:
- MacOS v10.14.4
- Ubuntu Linux (amd64) latest version

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.