How to call circleCI environment variable in an Angular 2+ project?












1















I have an angular project that has an api-keys.ts file that looks like this:



export var masterFirebaseConfig = {apiKey: $fireBaseApiKey, authDomain: 'dataJitsu.firebaseapp.com',databaseURL: 'https://datajitsu.firebaseio.com',storageBucket: '',messagingSenderId: '495992924984'};


I think the $fireBaseApiKey is stored as an environment variable in my project on circleCI, as you can see in the picture here:



enter image description here



However, I still get the following error when I run my configuration on circleCI:




ERROR in src/app/api-keys.ts(1,44): error TS2304: Cannot find name
'$fireBaseApiKey'. src/app/app.module.ts(75,11): error TS2304: Cannot
find name 'apiKey'.




(The error in app.module.ts comes directly from the error in api-keys.ts)



I tried to figure out whether the problem was on the circleCI side or with how I was plugging it into Angular, so I tried to echo out the environmental variable in my configuration file:



version: 2.1
orbs:
cypress: cypress-io/cypress@1.0.1
steps:
- run:
name: Setup Environment Variables
command: |
echo '$fireBaseApiKey'
workflows:
build:
jobs:
- cypress/install:
build: 'npm run build'
context: fireBaseApiKey
- cypress/run:
requires:
- cypress/install
start: 'npm start'
context: fireBaseApiKey


I ssh'ed into the session after it errored out, and I couldn't see any indication
that my echo command was even acknowledged.



I am hopeful that help on the echo front or on the Angular front will be productive to address the question/problem.



Furthermore, I am using cypress for integration testing and thus am using Cypress's orb for setting up and running the tests. I wasn't sure how to/whether environment variables to infiltrate orb jobs, so I also added the variable to a context for the project (with both the context and the key of the lone key-value pair having the same name):



enter image description here



Update: here is the output from the circleCI log file:




0 info it worked if it ends with ok 1 verbose cli [
'/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ] 2 info
using npm@6.4.1 3 info using node@v10.13.0 4 verbose run-script [
'prebuild', 'build', 'postbuild' ] 5 info lifecycle
data-jitsu@0.0.0~prebuild: data-jitsu@0.0.0 6 info lifecycle
data-jitsu@0.0.0~build: data-jitsu@0.0.0 7 verbose lifecycle
data-jitsu@0.0.0~build: unsafe-perm in lifecycle true 8 verbose
lifecycle data-jitsu@0.0.0~build: PATH:
/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/root/project/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle data-jitsu@0.0.0~build: CWD: /root/project 10
silly lifecycle data-jitsu@0.0.0~build: Args: [ '-c', 'ng build' ] 11
silly lifecycle data-jitsu@0.0.0~build: Returned: code: 1 signal:
null 12 info lifecycle data-jitsu@0.0.0~build: Failed to exec build
script 13 verbose stack Error: data-jitsu@0.0.0 build: ng build 13
verbose stack Exit status 1 13 verbose stack at
EventEmitter.
(/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13) 13
verbose stack at ChildProcess.
(/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13) 13
verbose stack at maybeClose (internal/child_process.js:962:16) 13
verbose stack at Process.ChildProcess._handle.onexit
(internal/child_process.js:251:5) 14 verbose pkgid data-jitsu@0.0.0 15
verbose cwd /root/project 16 verbose Linux 4.4.0-141-generic 17
verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v10.13.0 19 verbose npm v6.4.1 20 error code
ELIFECYCLE 21 error errno 1 22 error data-jitsu@0.0.0 build: ng
build
22 error Exit status 1 23 error Failed at the data-jitsu@0.0.0
build script. 23 error This is probably not a problem with npm. There
is likely additional logging output above. 24 verbose exit [ 1, true ]











share|improve this question





























    1















    I have an angular project that has an api-keys.ts file that looks like this:



    export var masterFirebaseConfig = {apiKey: $fireBaseApiKey, authDomain: 'dataJitsu.firebaseapp.com',databaseURL: 'https://datajitsu.firebaseio.com',storageBucket: '',messagingSenderId: '495992924984'};


    I think the $fireBaseApiKey is stored as an environment variable in my project on circleCI, as you can see in the picture here:



    enter image description here



    However, I still get the following error when I run my configuration on circleCI:




    ERROR in src/app/api-keys.ts(1,44): error TS2304: Cannot find name
    '$fireBaseApiKey'. src/app/app.module.ts(75,11): error TS2304: Cannot
    find name 'apiKey'.




    (The error in app.module.ts comes directly from the error in api-keys.ts)



    I tried to figure out whether the problem was on the circleCI side or with how I was plugging it into Angular, so I tried to echo out the environmental variable in my configuration file:



    version: 2.1
    orbs:
    cypress: cypress-io/cypress@1.0.1
    steps:
    - run:
    name: Setup Environment Variables
    command: |
    echo '$fireBaseApiKey'
    workflows:
    build:
    jobs:
    - cypress/install:
    build: 'npm run build'
    context: fireBaseApiKey
    - cypress/run:
    requires:
    - cypress/install
    start: 'npm start'
    context: fireBaseApiKey


    I ssh'ed into the session after it errored out, and I couldn't see any indication
    that my echo command was even acknowledged.



    I am hopeful that help on the echo front or on the Angular front will be productive to address the question/problem.



    Furthermore, I am using cypress for integration testing and thus am using Cypress's orb for setting up and running the tests. I wasn't sure how to/whether environment variables to infiltrate orb jobs, so I also added the variable to a context for the project (with both the context and the key of the lone key-value pair having the same name):



    enter image description here



    Update: here is the output from the circleCI log file:




    0 info it worked if it ends with ok 1 verbose cli [
    '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ] 2 info
    using npm@6.4.1 3 info using node@v10.13.0 4 verbose run-script [
    'prebuild', 'build', 'postbuild' ] 5 info lifecycle
    data-jitsu@0.0.0~prebuild: data-jitsu@0.0.0 6 info lifecycle
    data-jitsu@0.0.0~build: data-jitsu@0.0.0 7 verbose lifecycle
    data-jitsu@0.0.0~build: unsafe-perm in lifecycle true 8 verbose
    lifecycle data-jitsu@0.0.0~build: PATH:
    /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/root/project/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    9 verbose lifecycle data-jitsu@0.0.0~build: CWD: /root/project 10
    silly lifecycle data-jitsu@0.0.0~build: Args: [ '-c', 'ng build' ] 11
    silly lifecycle data-jitsu@0.0.0~build: Returned: code: 1 signal:
    null 12 info lifecycle data-jitsu@0.0.0~build: Failed to exec build
    script 13 verbose stack Error: data-jitsu@0.0.0 build: ng build 13
    verbose stack Exit status 1 13 verbose stack at
    EventEmitter.
    (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
    13 verbose stack at EventEmitter.emit (events.js:182:13) 13
    verbose stack at ChildProcess.
    (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
    13 verbose stack at ChildProcess.emit (events.js:182:13) 13
    verbose stack at maybeClose (internal/child_process.js:962:16) 13
    verbose stack at Process.ChildProcess._handle.onexit
    (internal/child_process.js:251:5) 14 verbose pkgid data-jitsu@0.0.0 15
    verbose cwd /root/project 16 verbose Linux 4.4.0-141-generic 17
    verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
    18 verbose node v10.13.0 19 verbose npm v6.4.1 20 error code
    ELIFECYCLE 21 error errno 1 22 error data-jitsu@0.0.0 build: ng
    build
    22 error Exit status 1 23 error Failed at the data-jitsu@0.0.0
    build script. 23 error This is probably not a problem with npm. There
    is likely additional logging output above. 24 verbose exit [ 1, true ]











    share|improve this question



























      1












      1








      1


      1






      I have an angular project that has an api-keys.ts file that looks like this:



      export var masterFirebaseConfig = {apiKey: $fireBaseApiKey, authDomain: 'dataJitsu.firebaseapp.com',databaseURL: 'https://datajitsu.firebaseio.com',storageBucket: '',messagingSenderId: '495992924984'};


      I think the $fireBaseApiKey is stored as an environment variable in my project on circleCI, as you can see in the picture here:



      enter image description here



      However, I still get the following error when I run my configuration on circleCI:




      ERROR in src/app/api-keys.ts(1,44): error TS2304: Cannot find name
      '$fireBaseApiKey'. src/app/app.module.ts(75,11): error TS2304: Cannot
      find name 'apiKey'.




      (The error in app.module.ts comes directly from the error in api-keys.ts)



      I tried to figure out whether the problem was on the circleCI side or with how I was plugging it into Angular, so I tried to echo out the environmental variable in my configuration file:



      version: 2.1
      orbs:
      cypress: cypress-io/cypress@1.0.1
      steps:
      - run:
      name: Setup Environment Variables
      command: |
      echo '$fireBaseApiKey'
      workflows:
      build:
      jobs:
      - cypress/install:
      build: 'npm run build'
      context: fireBaseApiKey
      - cypress/run:
      requires:
      - cypress/install
      start: 'npm start'
      context: fireBaseApiKey


      I ssh'ed into the session after it errored out, and I couldn't see any indication
      that my echo command was even acknowledged.



      I am hopeful that help on the echo front or on the Angular front will be productive to address the question/problem.



      Furthermore, I am using cypress for integration testing and thus am using Cypress's orb for setting up and running the tests. I wasn't sure how to/whether environment variables to infiltrate orb jobs, so I also added the variable to a context for the project (with both the context and the key of the lone key-value pair having the same name):



      enter image description here



      Update: here is the output from the circleCI log file:




      0 info it worked if it ends with ok 1 verbose cli [
      '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ] 2 info
      using npm@6.4.1 3 info using node@v10.13.0 4 verbose run-script [
      'prebuild', 'build', 'postbuild' ] 5 info lifecycle
      data-jitsu@0.0.0~prebuild: data-jitsu@0.0.0 6 info lifecycle
      data-jitsu@0.0.0~build: data-jitsu@0.0.0 7 verbose lifecycle
      data-jitsu@0.0.0~build: unsafe-perm in lifecycle true 8 verbose
      lifecycle data-jitsu@0.0.0~build: PATH:
      /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/root/project/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      9 verbose lifecycle data-jitsu@0.0.0~build: CWD: /root/project 10
      silly lifecycle data-jitsu@0.0.0~build: Args: [ '-c', 'ng build' ] 11
      silly lifecycle data-jitsu@0.0.0~build: Returned: code: 1 signal:
      null 12 info lifecycle data-jitsu@0.0.0~build: Failed to exec build
      script 13 verbose stack Error: data-jitsu@0.0.0 build: ng build 13
      verbose stack Exit status 1 13 verbose stack at
      EventEmitter.
      (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
      13 verbose stack at EventEmitter.emit (events.js:182:13) 13
      verbose stack at ChildProcess.
      (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
      13 verbose stack at ChildProcess.emit (events.js:182:13) 13
      verbose stack at maybeClose (internal/child_process.js:962:16) 13
      verbose stack at Process.ChildProcess._handle.onexit
      (internal/child_process.js:251:5) 14 verbose pkgid data-jitsu@0.0.0 15
      verbose cwd /root/project 16 verbose Linux 4.4.0-141-generic 17
      verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
      18 verbose node v10.13.0 19 verbose npm v6.4.1 20 error code
      ELIFECYCLE 21 error errno 1 22 error data-jitsu@0.0.0 build: ng
      build
      22 error Exit status 1 23 error Failed at the data-jitsu@0.0.0
      build script. 23 error This is probably not a problem with npm. There
      is likely additional logging output above. 24 verbose exit [ 1, true ]











      share|improve this question
















      I have an angular project that has an api-keys.ts file that looks like this:



      export var masterFirebaseConfig = {apiKey: $fireBaseApiKey, authDomain: 'dataJitsu.firebaseapp.com',databaseURL: 'https://datajitsu.firebaseio.com',storageBucket: '',messagingSenderId: '495992924984'};


      I think the $fireBaseApiKey is stored as an environment variable in my project on circleCI, as you can see in the picture here:



      enter image description here



      However, I still get the following error when I run my configuration on circleCI:




      ERROR in src/app/api-keys.ts(1,44): error TS2304: Cannot find name
      '$fireBaseApiKey'. src/app/app.module.ts(75,11): error TS2304: Cannot
      find name 'apiKey'.




      (The error in app.module.ts comes directly from the error in api-keys.ts)



      I tried to figure out whether the problem was on the circleCI side or with how I was plugging it into Angular, so I tried to echo out the environmental variable in my configuration file:



      version: 2.1
      orbs:
      cypress: cypress-io/cypress@1.0.1
      steps:
      - run:
      name: Setup Environment Variables
      command: |
      echo '$fireBaseApiKey'
      workflows:
      build:
      jobs:
      - cypress/install:
      build: 'npm run build'
      context: fireBaseApiKey
      - cypress/run:
      requires:
      - cypress/install
      start: 'npm start'
      context: fireBaseApiKey


      I ssh'ed into the session after it errored out, and I couldn't see any indication
      that my echo command was even acknowledged.



      I am hopeful that help on the echo front or on the Angular front will be productive to address the question/problem.



      Furthermore, I am using cypress for integration testing and thus am using Cypress's orb for setting up and running the tests. I wasn't sure how to/whether environment variables to infiltrate orb jobs, so I also added the variable to a context for the project (with both the context and the key of the lone key-value pair having the same name):



      enter image description here



      Update: here is the output from the circleCI log file:




      0 info it worked if it ends with ok 1 verbose cli [
      '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ] 2 info
      using npm@6.4.1 3 info using node@v10.13.0 4 verbose run-script [
      'prebuild', 'build', 'postbuild' ] 5 info lifecycle
      data-jitsu@0.0.0~prebuild: data-jitsu@0.0.0 6 info lifecycle
      data-jitsu@0.0.0~build: data-jitsu@0.0.0 7 verbose lifecycle
      data-jitsu@0.0.0~build: unsafe-perm in lifecycle true 8 verbose
      lifecycle data-jitsu@0.0.0~build: PATH:
      /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/root/project/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      9 verbose lifecycle data-jitsu@0.0.0~build: CWD: /root/project 10
      silly lifecycle data-jitsu@0.0.0~build: Args: [ '-c', 'ng build' ] 11
      silly lifecycle data-jitsu@0.0.0~build: Returned: code: 1 signal:
      null 12 info lifecycle data-jitsu@0.0.0~build: Failed to exec build
      script 13 verbose stack Error: data-jitsu@0.0.0 build: ng build 13
      verbose stack Exit status 1 13 verbose stack at
      EventEmitter.
      (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
      13 verbose stack at EventEmitter.emit (events.js:182:13) 13
      verbose stack at ChildProcess.
      (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
      13 verbose stack at ChildProcess.emit (events.js:182:13) 13
      verbose stack at maybeClose (internal/child_process.js:962:16) 13
      verbose stack at Process.ChildProcess._handle.onexit
      (internal/child_process.js:251:5) 14 verbose pkgid data-jitsu@0.0.0 15
      verbose cwd /root/project 16 verbose Linux 4.4.0-141-generic 17
      verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
      18 verbose node v10.13.0 19 verbose npm v6.4.1 20 error code
      ELIFECYCLE 21 error errno 1 22 error data-jitsu@0.0.0 build: ng
      build
      22 error Exit status 1 23 error Failed at the data-jitsu@0.0.0
      build script. 23 error This is probably not a problem with npm. There
      is likely additional logging output above. 24 verbose exit [ 1, true ]








      angular cypress circleci-2.0 circleci-workflows






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 20 at 0:33







      Atticus29

















      asked Jan 19 at 3:27









      Atticus29Atticus29

      841102553




      841102553
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Have you tried echo $fireBaseApiKey (without quotes)?



          To troubleshoot CircleCI, it's useful to launch an image locally.



          Example: the command below will launch a local ubuntu instance with an environment variable fireBaseApiKey set to asdf-asdf-asdf. Your local files will be mounted in /usr/src/app.



          docker run -it -e fireBaseApiKey=asdf-asdf-asdf -v $PWD:/usr/src/app ubuntu bash


          To check your environment variable, try:



          echo $fireBaseApiKey


          cd /usr/src/app and run your build script, step by step. I find it useful to troubleshoot builds failing for unknown reasons.






          share|improve this answer
























          • Thanks, @Andre Castoldi! I can see my environment variable in the local ubuntu instance per your instructions above, but I still can't see it in my log files on circleCI when I remove the single quotes. I'll be sure to add what I see in my circleCI logfile above.

            – Atticus29
            Jan 20 at 0:32











          • Also, the local ubuntu instance looks like it doesn't have npm installed, etc., which all seem to be taken care of with the cypress orb in my config. file. I see theoretically how using a local ubuntu instance would be helpful for troubleshooting, but I'm afraid I'm not equipped to figure out how to run orbs locally.

            – Atticus29
            Jan 20 at 0:32











          • In any case, I think what is really needed is an example of how someone else runs cypress on their angular project while keeping API keys private by using environment variables. I can't seem to find a good example of that (in particular, what the config scrip would look like).

            – Atticus29
            Jan 20 at 0:32











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54263826%2fhow-to-call-circleci-environment-variable-in-an-angular-2-project%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Have you tried echo $fireBaseApiKey (without quotes)?



          To troubleshoot CircleCI, it's useful to launch an image locally.



          Example: the command below will launch a local ubuntu instance with an environment variable fireBaseApiKey set to asdf-asdf-asdf. Your local files will be mounted in /usr/src/app.



          docker run -it -e fireBaseApiKey=asdf-asdf-asdf -v $PWD:/usr/src/app ubuntu bash


          To check your environment variable, try:



          echo $fireBaseApiKey


          cd /usr/src/app and run your build script, step by step. I find it useful to troubleshoot builds failing for unknown reasons.






          share|improve this answer
























          • Thanks, @Andre Castoldi! I can see my environment variable in the local ubuntu instance per your instructions above, but I still can't see it in my log files on circleCI when I remove the single quotes. I'll be sure to add what I see in my circleCI logfile above.

            – Atticus29
            Jan 20 at 0:32











          • Also, the local ubuntu instance looks like it doesn't have npm installed, etc., which all seem to be taken care of with the cypress orb in my config. file. I see theoretically how using a local ubuntu instance would be helpful for troubleshooting, but I'm afraid I'm not equipped to figure out how to run orbs locally.

            – Atticus29
            Jan 20 at 0:32











          • In any case, I think what is really needed is an example of how someone else runs cypress on their angular project while keeping API keys private by using environment variables. I can't seem to find a good example of that (in particular, what the config scrip would look like).

            – Atticus29
            Jan 20 at 0:32
















          1














          Have you tried echo $fireBaseApiKey (without quotes)?



          To troubleshoot CircleCI, it's useful to launch an image locally.



          Example: the command below will launch a local ubuntu instance with an environment variable fireBaseApiKey set to asdf-asdf-asdf. Your local files will be mounted in /usr/src/app.



          docker run -it -e fireBaseApiKey=asdf-asdf-asdf -v $PWD:/usr/src/app ubuntu bash


          To check your environment variable, try:



          echo $fireBaseApiKey


          cd /usr/src/app and run your build script, step by step. I find it useful to troubleshoot builds failing for unknown reasons.






          share|improve this answer
























          • Thanks, @Andre Castoldi! I can see my environment variable in the local ubuntu instance per your instructions above, but I still can't see it in my log files on circleCI when I remove the single quotes. I'll be sure to add what I see in my circleCI logfile above.

            – Atticus29
            Jan 20 at 0:32











          • Also, the local ubuntu instance looks like it doesn't have npm installed, etc., which all seem to be taken care of with the cypress orb in my config. file. I see theoretically how using a local ubuntu instance would be helpful for troubleshooting, but I'm afraid I'm not equipped to figure out how to run orbs locally.

            – Atticus29
            Jan 20 at 0:32











          • In any case, I think what is really needed is an example of how someone else runs cypress on their angular project while keeping API keys private by using environment variables. I can't seem to find a good example of that (in particular, what the config scrip would look like).

            – Atticus29
            Jan 20 at 0:32














          1












          1








          1







          Have you tried echo $fireBaseApiKey (without quotes)?



          To troubleshoot CircleCI, it's useful to launch an image locally.



          Example: the command below will launch a local ubuntu instance with an environment variable fireBaseApiKey set to asdf-asdf-asdf. Your local files will be mounted in /usr/src/app.



          docker run -it -e fireBaseApiKey=asdf-asdf-asdf -v $PWD:/usr/src/app ubuntu bash


          To check your environment variable, try:



          echo $fireBaseApiKey


          cd /usr/src/app and run your build script, step by step. I find it useful to troubleshoot builds failing for unknown reasons.






          share|improve this answer













          Have you tried echo $fireBaseApiKey (without quotes)?



          To troubleshoot CircleCI, it's useful to launch an image locally.



          Example: the command below will launch a local ubuntu instance with an environment variable fireBaseApiKey set to asdf-asdf-asdf. Your local files will be mounted in /usr/src/app.



          docker run -it -e fireBaseApiKey=asdf-asdf-asdf -v $PWD:/usr/src/app ubuntu bash


          To check your environment variable, try:



          echo $fireBaseApiKey


          cd /usr/src/app and run your build script, step by step. I find it useful to troubleshoot builds failing for unknown reasons.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 19 at 22:25









          Andre CastoldiAndre Castoldi

          14615




          14615













          • Thanks, @Andre Castoldi! I can see my environment variable in the local ubuntu instance per your instructions above, but I still can't see it in my log files on circleCI when I remove the single quotes. I'll be sure to add what I see in my circleCI logfile above.

            – Atticus29
            Jan 20 at 0:32











          • Also, the local ubuntu instance looks like it doesn't have npm installed, etc., which all seem to be taken care of with the cypress orb in my config. file. I see theoretically how using a local ubuntu instance would be helpful for troubleshooting, but I'm afraid I'm not equipped to figure out how to run orbs locally.

            – Atticus29
            Jan 20 at 0:32











          • In any case, I think what is really needed is an example of how someone else runs cypress on their angular project while keeping API keys private by using environment variables. I can't seem to find a good example of that (in particular, what the config scrip would look like).

            – Atticus29
            Jan 20 at 0:32



















          • Thanks, @Andre Castoldi! I can see my environment variable in the local ubuntu instance per your instructions above, but I still can't see it in my log files on circleCI when I remove the single quotes. I'll be sure to add what I see in my circleCI logfile above.

            – Atticus29
            Jan 20 at 0:32











          • Also, the local ubuntu instance looks like it doesn't have npm installed, etc., which all seem to be taken care of with the cypress orb in my config. file. I see theoretically how using a local ubuntu instance would be helpful for troubleshooting, but I'm afraid I'm not equipped to figure out how to run orbs locally.

            – Atticus29
            Jan 20 at 0:32











          • In any case, I think what is really needed is an example of how someone else runs cypress on their angular project while keeping API keys private by using environment variables. I can't seem to find a good example of that (in particular, what the config scrip would look like).

            – Atticus29
            Jan 20 at 0:32

















          Thanks, @Andre Castoldi! I can see my environment variable in the local ubuntu instance per your instructions above, but I still can't see it in my log files on circleCI when I remove the single quotes. I'll be sure to add what I see in my circleCI logfile above.

          – Atticus29
          Jan 20 at 0:32





          Thanks, @Andre Castoldi! I can see my environment variable in the local ubuntu instance per your instructions above, but I still can't see it in my log files on circleCI when I remove the single quotes. I'll be sure to add what I see in my circleCI logfile above.

          – Atticus29
          Jan 20 at 0:32













          Also, the local ubuntu instance looks like it doesn't have npm installed, etc., which all seem to be taken care of with the cypress orb in my config. file. I see theoretically how using a local ubuntu instance would be helpful for troubleshooting, but I'm afraid I'm not equipped to figure out how to run orbs locally.

          – Atticus29
          Jan 20 at 0:32





          Also, the local ubuntu instance looks like it doesn't have npm installed, etc., which all seem to be taken care of with the cypress orb in my config. file. I see theoretically how using a local ubuntu instance would be helpful for troubleshooting, but I'm afraid I'm not equipped to figure out how to run orbs locally.

          – Atticus29
          Jan 20 at 0:32













          In any case, I think what is really needed is an example of how someone else runs cypress on their angular project while keeping API keys private by using environment variables. I can't seem to find a good example of that (in particular, what the config scrip would look like).

          – Atticus29
          Jan 20 at 0:32





          In any case, I think what is really needed is an example of how someone else runs cypress on their angular project while keeping API keys private by using environment variables. I can't seem to find a good example of that (in particular, what the config scrip would look like).

          – Atticus29
          Jan 20 at 0:32


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54263826%2fhow-to-call-circleci-environment-variable-in-an-angular-2-project%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Homophylophilia

          Updating UILabel text programmatically using a function

          Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage