<p>I am currently implementing a CI Pipeline using Tekton. I was wondering if there is a way to use some kind of <code>valueFromEnv</code> for pipeline params.</p>
<p>For example to authenticate a Task for sonarqube analysis with my company's sonar host i need the login token, which I would rather want to insert via reference to a secret than passing it directly.</p>
<p>As I am relatively new to tekton I am unsure if I just haven't grasped the tekton way of doing this. Two possibilities that crossed my mind were:</p>
<ol>
<li>A &quot;Pre-Task&quot; which reads the env in it's step definition and publishes it as a result (which then can be used as param to the next Task)</li>
<li>Mounting the secret as a file for the Task to load the secret (e.g. by <code>cat</code>ting it)</li>
</ol>
<p>Both of those ideas do not feel like I should do it this way, but maybe I am wrong here.</p>
<p>Any help is appreciated!</p>

René Jahn
<p>Your first Idea is not impossible, but in my eyes ugly as well. You can set the desired ENV in your image via DockerFile and use it later in the task:</p>
<p>Docker file (example):</p>
<pre><code>FROM gradle:7.4-jdk11    
USER root    
RUN apt-get update &amp;&amp; apt-get install -y npm    

YOUR_VARIABLE_KEY=&quot;any VALUE&quot;
</code></pre>
<p>afterwards you can just use it in script tasks like:</p>
<pre><code>echo $YOUR_VARIABLE_KEY
</code></pre>
<p><strong>RECOMMENDED (for Openshift)</strong></p>
<p>The cleaner way is, to define it as Secret (Key/value) or as a SealeedSecret (Opaque)</p>
<p>this can be done directly within the namespace on the openshift-UI or as Code.</p>
<p>Next step is to &quot;bind&quot; it in your task:</p>

<pre><code>spec:
  description: |-
    any
  params:
    - name: any-secret-name
      default: &quot;any-secret&quot;
      type: string
  stepTemplate:
    name: &quot;&quot;
    resources:
      limits:
        cpu: 1500m
        memory: 4Gi
      requests:
        cpu: 250m
        memory: 500Mi
  steps:
    - image: $(params.BUILDER_IMAGE)
      name: posting
      resources:
        limits:
          cpu: 1500m
          memory: 4Gi
        requests:
          cpu: 250m
          memory: 500Mi
      env:
        - name: YOU_NAME_IT
          valueFrom:
            secretKeyRef:
              name: $(params.any-secret-name)
              key: &quot;any-secret-key&quot;
      script: |
        #!/usr/bin/env sh
        set -eu

        set +x
        echo $YOU_NAME_IT
        set -x
</code></pre>
<p><strong>BEWARE!!!</strong> If you run it that way - nothing should be logged - if you leave out <code>set +x</code> before and <code>set -x</code> after the <code>echo</code> it is logged.</p>
<p>Now I saw you're may not working in openshift - here is the kubernetes page: <a href="https://kubernetes.io/docs/concepts/configuration/secret/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/secret/</a> =&gt; Using Secrets as environment variables  (is close to your first idea - but the whole page looks like good cookbook)</p>
