Unable push the code into elastic journey

Follow the example,

In the synthetics.config.ts, i have provided the request value

    project: {
      id: xxx,
      url: xxx,
      space: xxx,
    },

Run this command,
SYNTHETICS_API_KEY= npm run push

Why does such an error occur?

Thanks for reaching out, @xyngfei. The error seems to indicate that the configuration isn't correctly set. I have a few questions here:

  • Did you use the wizard to set your your enviroment?

    Usually I get started like so:

    npm install -g @elastic/synthetics 
    npx @elastic/synthetics init your-project-name
    
  • What directory are you when you run SYNTHETICS_API_KEY=<value> npm run push?

I have some resources I've created on this subject on my GitHub which may be helpful.

1 Like

@jessgarson

  1. I didn't use the wizard to set on my local enviroment because i need to simualate on the CICD environment with a single command line can push the code the elastic.
  2. directory to run the code in same level with the node_modules folder
limxf@xf-lim-mml85 cmp-journey % ls
README.md               journeys                output                  package.json            synthetics.
cred.txt                node_modules            package-lock.json       pages                   utils
limxf@xf-lim-mml85 cmp-journey % SYNTHETICS_API_KEY=<key> DEBUG=synthetics npm run push

> elastic-synthetic-journeys@1.0.0 push
> npx @elastic/synthetics push --yes

at 6361 ms Processing file: xxx/journeys/journey.ts
at 7049 ms Journey register: "Journey"
env: development
Aborted (missing synthetics config file), Project not set up correctly.

Run 'npx @elastic/synthetics init' to create project with default settings.

Somehow when I used the same push command, it can work well on the CICD environment. It is puzzling me a lot

If I don't install @elastic/synthetics globally, only under node_module folder, and trigger the following command to push, by right, it should work?

npx @elastic/synthetics push --yes

Thanks for following up, @xyngfei. What CI/CD enviorment are you using?

For something like GitHub actions, you can use a YAML file that would look something like this:

on: [push]

jobs:
  setup_synthetics:
    runs-on: ubuntu-latest
    steps:
    - name: Check out repository
      uses: actions/checkout@v2

    - name: Set up Node.js
      uses: actions/setup-node@v3
      with:
        node-version: '16'  

    - name: Install Elastic Synthetics
      run: npm install -g @elastic/synthetics

    - name: Initialize Synthetics
      run: npx @elastic/synthetics init ${{ github.event.repository.name }}
1 Like

@jessgarson

Yes, I noticed that our GitLab runner has installed the synthetics globally, that is the reason it can run successfully on the CICD pipeline.

besides, I also made a mistake, I didn't setup the environment file properly due to the code issue.

I appreciate your speedy reply and solution to address this issue.

Thanks, @xyngfei. Do you need any further support here, or should I mark this sloved?

@jessgarson yes, you can mark it as solved :slight_smile:

1 Like