PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 19, 2022

[FIXED] How to use File environment variable in Gitlab CI

 August 19, 2022     continuous-integration, environment-variables, gitlab, gitlab-ci     No comments   

Issue

I have a private key for deployment which I have set as a File Environment variable in the gitlab ci settings. However when I try and do

echo $VAR

the output is the entire contents of the key something like

----BEGIN PRIVATE KEY---
dfbvjladfbgvjksadbavkjabdfjnvkdjbnv;sdf98qw374yriuebglvkjsdfgydjkfvnldafkjbvgjkaldb
----END PRIVATE KEY---

I would like to have this key stored in a file and would like the path to the file as the environment variable $VAR. I am unsure of how to do this. Any help will be appreciated.


Solution

There was a couple of mistakes with respect to using the Environment variables.

The environment variables when declared in settings need not be imported in the yaml files as variables.

Mistake

variables:
    VAR : $VAR

This leads to the contents of the file being exposed in the log which we dont want in this case.

Correct Way:

We can just use the key as is in the yaml with $VAR this should give a temporary path to the file where the key is stored.



Answered By - Abinav R
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing