<p>I am new to devops and I am having the following problem:</p>

<p>I have cloudbuild file which configured to generate deployment for namespace named after tag.</p>

<p>For example: for tag <strong>v1.0.2/host/dev</strong> it should generate new deployment at "dev" namespace.</p>

<p>Here is part of cloudbuild.yaml code:</p>

<pre><code>  - name: 'gcr.io/cloud-builders/gcloud'
    entrypoint: 'bash'
    args:
    - '-c'
    - |
        export APP_VERSION
        export NAMESPACE
        export CLUSTER_NAME
        IFS=/ read -r APP_VERSION CLUSTER_NAME NAMESPACE &lt;&lt;&lt; "$TAG_NAME"

        ... here is my problem ...
        export ENVIRONMENT
        export X
        export XX
        IFS=/ read -r X XX ENVIRONMENT &lt;&lt;&lt; "$TAG_NAME"
        ...
</code></pre>

<p>As you can see - variable NAMESPACE is set with last part of tag (like "dev")</p>

<p>Later in code i need to set one more variable - ENVIRONMENT - with same value ("dev"). I did it by copy the way it done before and use some X and XX unused variables.</p>

<p>How can this be done in more accurate way?
I tried:</p>

<pre><code>export ENVIRONMENT=NAMESPACE
</code></pre>

<p>Or:</p>

<pre><code>export ENVIRONMENT=${NAMESPACE}
</code></pre>

<p>Any ideas?</p>

happyZZR1400
<p>This should do it:</p>

<pre><code>export ENVIRONMENT=${NAMESPACE}
</code></pre>

<p>Basically, you are doing an </p>

<pre><code>export NAMESPACE
</code></pre>

<p>before the said assignment and in bash <code>NAMESPACE</code> should be available as a variable ${NAMESPACE}</p>
