datreeio / datree

Prevent Kubernetes misconfigurations from reaching production (again 😤 )! From code to cloud, Datree provides an E2E policy enforcement solution to run automatic checks for rule violations. See our docs: https://hub.datree.io
https://datree.io
Apache License 2.0
6.39k stars 363 forks source link

Error: unknown command "datree" for "helm" #348

Closed shravankumar88 closed 2 years ago

shravankumar88 commented 2 years ago

Describe the bug In Jenkins when I run the script pipeline { agent any stages { stage ("identifying misconfigure using datree in helm charts") { steps { dir('kubernetes/') { sh 'helm datree test myapp' } } } } } Getting exception: Running in /var/lib/jenkins/workspace/sampleweb/kubernetes [Pipeline] { [Pipeline] sh

To Reproduce Steps to reproduce the behavior:

  1. Configured the Jenkins and installed the plugin: helm plugin install https://github.com/datreeio/helm-datree
  2. For reference sharing the code : https://github.com/shravankumar88/sampleweb.git
  3. Created a pipeline job and in Jenkinsfile mentioned the above script and run the job
  4. Getting the exception : unknown command "datree" for "helm"
  5. Installed the datree using curl https://get.datree.io | /bin/bash
  6. And re-run the job getting same exception
  7. But when I login into the machine and run the cmd: helm datree test myapp it is working
  8. Jenkins Version: 2.319.1 and helm datree version: 0.14.85

Expected behavior Schema validation and provide policy rules Screenshots Started by user shravan kumar Replayed #101 [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /var/lib/jenkins/workspace/sampleweb [Pipeline] { [Pipeline] stage [Pipeline] { (Declarative: Checkout SCM) [Pipeline] checkout Selected Git installation does not exist. Using Default The recommended git tool is: NONE using credential jenkinsAuth-BitBucket

/usr/bin/git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/sampleweb/.git # timeout=10 Fetching changes from the remote Git repository /usr/bin/git config remote.sample-web.url url # timeout=10 Fetching upstream changes from url /usr/bin/git --version # timeout=10 git --version # 'git version 2.17.1' using GIT_ASKPASS to set credentials jenkinsAuth-BitBucket /usr/bin/git fetch --tags --progress -- url +refs/heads/:refs/remotes/sample-web/ # timeout=10 /usr/bin/git rev-parse refs/remotes/sample-web/feature^{commit} # timeout=10 Checking out Revision cd7d058a9de59b5b25817481233b1694ca80f7e1 (refs/remotes/sample-web/feature) /usr/bin/git config core.sparsecheckout # timeout=10 /usr/bin/git checkout -f cd7d058a9de59b5b25817481233b1694ca80f7e1 # timeout=10 Commit message: "jenkisfile change" /usr/bin/git rev-list --no-walk cd7d058a9de59b5b25817481233b1694ca80f7e1 # timeout=10 Posting build status of INPROGRESS to bitbucket for commit id [cd7d058a9de59b5b25817481233b1694ca80f7e1] and ref 'refs/heads/feature' [Pipeline] } [Pipeline] // stage [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (indentifying misconfig using datree in helm charts) [Pipeline] dir Running in /var/lib/jenkins/workspace/sampleweb/kubernetes [Pipeline] { [Pipeline] withEnv [Pipeline] { [Pipeline] } [Pipeline] // withEnv [Pipeline] sh

  • helm datree test myapp/ Error: unknown command "datree" for "helm" Run 'helm --help' for usage. [Pipeline] } [Pipeline] // dir [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code 1 Posting build status of FAILED to bitbucket for commit id [cd7d058a9de59b5b25817481233b1694ca80f7e1] and ref 'refs/heads/feature' Finished: FAILURE

Desktop (please complete the following information):

Datree version (run datree version):

Additional context
Add any other context about the problem here.
If possible, include a YAML file to reproduce the bug.

alexfedin commented 2 years ago

@shravankumar88 from what it looks like the node that executing the pipeline does not have datree plugin installed on helm, Is there a chance that the machine you installed datree plugin on is not the same that executes the pipeline? Alternatively, you can add the command helm plugin install https://github.com/datreeio/helm-datree in the pipeline before running the datree test command

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.