<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sachin Kumar Singh</title>
    <description>The latest articles on DEV Community by Sachin Kumar Singh (@sachinksingh28).</description>
    <link>https://dev.to/sachinksingh28</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2728059%2F4db706b9-4c9f-4bda-afe8-ffbd8b1030c3.jpeg</url>
      <title>DEV Community: Sachin Kumar Singh</title>
      <link>https://dev.to/sachinksingh28</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sachinksingh28"/>
    <language>en</language>
    <item>
      <title>Using environment variables in melange</title>
      <dc:creator>Sachin Kumar Singh</dc:creator>
      <pubDate>Fri, 17 Jan 2025 11:18:57 +0000</pubDate>
      <link>https://dev.to/sachinksingh28/using-environment-variables-in-melange-gmo</link>
      <guid>https://dev.to/sachinksingh28/using-environment-variables-in-melange-gmo</guid>
      <description>&lt;p&gt;It is so simple to use environment variable when building a apko package using melange yet I couldn't find an examples to make a developers life easy so here is my attempt for that -&lt;/p&gt;

&lt;h3&gt;
  
  
  Create the env file with required variables
&lt;/h3&gt;

&lt;p&gt;Example below shows a way to add some predefined gitlab CI variables allowing you to clone the repository -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    - echo CI_JOB_TOKEN=$CI_JOB_TOKEN &amp;gt;&amp;gt; .env
    - echo CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME &amp;gt;&amp;gt; .env
    - echo CI_SERVER_FQDN=$CI_SERVER_FQDN &amp;gt;&amp;gt; .env

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Update melange yaml to use the variables
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
package:
  name: sample-app
...
...
vars:
  CI_JOB_TOKEN: ${CI_JOB_TOKEN}

pipeline:
  - working-directory: /home/user
    pipeline:
      - runs: |
          git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_FQDN}/some-group/some-project -b $CI_COMMIT_REF_NAME
          APP_HOME="${{targets.destdir}}/opt/app"
          mkdir -p ${APP_HOME}
          pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Run melange build
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;melange build --signing-key melange.rsa --env-file .env --runner bubblewrap --rm --namespace xyz --out-dir some-dir --cache-dir another-dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So easy! &lt;/p&gt;

</description>
      <category>melange</category>
    </item>
  </channel>
</rss>
