I am using gulpfile.js in my project to download files and it is working fine.
var shell = require('gulp-shell');
gulp.task('folder_xyz', shell.task('curl --output xyz.zip --header "PRIVATE-TOKEN: theyuuin_io2_kj" "https://example.com/api/v4/download?job=xyz"'));
here everything is working fine and i am able to download the file. However i have set environment variable in GitLab called download_folder_xyz
. Now i want to use this environment, want to replace Private token with new variable download_folder_xyz
in the gulp.task()
how can i do this ?
You can access any environment variable in nodejs via process.env object. Let's see an example. Assuming you want to access download_folder_xyz that is a environment variable
var shell = require('gulp-shell');
gulp.task('folder_xyz', shell.task(`curl --output xyz.zip --header "PRIVATE-TOKEN: ${process.env.download_folder_xyz}" "https://example.com/api/v4/download?job=xyz"`));