<p>It sounds like the issue is related to the <strong>PATH</strong> environment variable not being set correctly for the kubectl krew command.</p>
<ul>
<li>Set the <strong>PATH</strong> in the Pipeline Script
<pre><code>environment {
    PATH = &quot;${env.PATH}:${env.HOME}/.krew/bin&quot;
}
</code></pre>
</li>
<li>Use the <strong>withEnv</strong> Step
<pre><code>script {
    withEnv([&quot;PATH=${env.PATH}:${env.HOME}/.krew/bin&quot;]) {
        sh 'kubectl krew install hlf'
    }
}
</code></pre>
</li>
<li>Update the <strong>Node Configuration</strong>
<strong>Manage Jenkins &gt; Manage Nodes and Clouds. &gt; Your Node &gt; Configure &gt; Node Properties &gt; Environment Variables</strong>
<pre><code>PATH = &quot;${env.PATH}:${env.HOME}/.krew/bin&quot;
</code></pre>
</li>
</ul>

CC BY-SA 4.0
2024-08-16T16:46:42.190Z
2024-08-16T17:43:03.153Z
2024-08-16T17:43:03.153Z
YassineLbk
<p>I'm new to jenkins . I have written a jenkins pipeline to create blockchain network using HLF Operator.
I've installed kubectl on the vm and used it as node in jenkins.
The kubectl commands and other work fine but I'm facing issues when it comes to krew.</p>
<p>If I run the pipeline stages steps with</p>
<pre><code> stage('Install Krew HLF'){
    steps{
        script{
            sh 'export PATH=&quot;${KREW_ROOT:-$HOME/.krew}/bin:$PATH&quot; &amp;&amp; kubectl krew install hlf '
        }
    }
</code></pre>
<p>But when I use the command without the export part , it fails.</p>
<p>How am I supposed to tackle this.</p>

CC BY-SA 4.0
2024-02-22T14:32:21.333Z
This got resolved . The issue was with the path variable . I made these changes in my pipeline.  environment{
        PATH = "${PATH}:/home/xyz/.krew/bin"
    }
Haaris Khatri
<kubernetes><jenkins><jenkins-pipeline><cicd>
How to work with krew in Jenkins?
Haaris Khatri
# How to work with krew in Jenkins?

(Asked by: username_0 on 2024-02-21)

I'm new to jenkins . I have written a jenkins pipeline to create blockchain network using HLF Operator.
I've installed kubectl on the vm and used it as node in jenkins.
The kubectl commands and other work fine but I'm facing issues when it comes to krew.
If I run the pipeline stages steps with
 stage('Install Krew HLF'){
    steps{
        script{
            sh 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" && kubectl krew install hlf '
        }
    }

But when I use the command without the export part , it fails.
How am I supposed to tackle this.

**Tags:** kubernetes, jenkins, jenkins-pipeline, cicd

> **Comments:**
> **username_0**: This got resolved . The issue was with the path variable . I made these changes in my pipeline.  environment{         PATH = "${PATH}:/home/xyz/.krew/bin"     }  

---

## 1 answers

### Answer by username_1 on 2024-08-16. Score: 1

It sounds like the issue is related to the PATH environment variable not being set correctly for the kubectl krew command.

Set the PATH in the Pipeline Script
environment {
    PATH = "${env.PATH}:${env.HOME}/.krew/bin"
}


Use the withEnv Step
script {
    withEnv(["PATH=${env.PATH}:${env.HOME}/.krew/bin"]) {
        sh 'kubectl krew install hlf'
    }
}


Update the Node Configuration
Manage Jenkins > Manage Nodes and Clouds. > Your Node > Configure > Node Properties > Environment Variables
PATH = "${env.PATH}:${env.HOME}/.krew/bin"


---

