<p>You can store secret file at Jenkins and use it for deployment.
It can be achieved by using <a href="https://plugins.jenkins.io/credentials/" rel="nofollow noreferrer">Credentials</a> and <a href="https://plugins.jenkins.io/credentials-binding/" rel="nofollow noreferrer">Credentials Binding</a> plugins.</p>
<ol>
<li>Install Credentials Binding and Credentials plugins</li>
<li>Select your user name in the top navigation bar.</li>
<li>Select Credentials in the left pane.</li>
<li>Under Stores from parent, select (global) in the Domains column.</li>
<li>Select Add Credentials in the left pane.
<a href="https://i.sstatic.net/wCUk4.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wCUk4.png" alt="enter image description here" /></a></li>
<li>insert into your pipeline script</li>
</ol>
<pre>  
withCredentials([file(credentialsId: 'env', variable: 'mySecretEnvFile')]){
    sh 'cp $mySecretEnvFile $WORKSPACE'
}
</pre>

CC BY-SA 4.0
2021-01-05T19:32:21.080Z
2021-01-05T19:32:21.080Z
Evgeny Anikiev
<p>how to update the .env file in production while Jenkins deployment?
we have not committed the .env file in git for security reasons.</p>

<jenkins><jenkins-pipeline>
how to update .env file in production while Jenkins deployment
Subhash
# how to update .env file in production while Jenkins deployment

(Asked by: username_0 on 2021-01-05)

how to update the .env file in production while Jenkins deployment?
we have not committed the .env file in git for security reasons.

**Tags:** jenkins, jenkins-pipeline


---

## 1 answers

### Answer by username_1 on 2021-01-05. Score: 4 | Accepted answer

You can store secret file at Jenkins and use it for deployment.
It can be achieved by using Credentials and Credentials Binding plugins.

Install Credentials Binding and Credentials plugins
Select your user name in the top navigation bar.
Select Credentials in the left pane.
Under Stores from parent, select (global) in the Domains column.
Select Add Credentials in the left pane.

insert into your pipeline script

  
withCredentials([file(credentialsId: 'env', variable: 'mySecretEnvFile')]){
    sh 'cp $mySecretEnvFile $WORKSPACE'
}


---

