# CircleCI

Mobb can be integrated into any CI/CD platform of your choice. In this guide, the process of integration with CircleCI will be demonstrated.

After logging into Mobb, select the last option in the menu: “**Connect Mobb to Your Workflow**”.

<figure><img src="/files/T16LJajPr4sX1eMDefxo" alt="" width="563"><figcaption></figcaption></figure>

To run Mobb within CircleCI, select “**CircleCI**”.

You will be presented with a sample `yaml` script that you can use in CircleCI. This particular example uses Snyk as the SAST scanner, however, you may want to modify the script to use the SAST tool of your choice.

```yaml
version: 2.1
orbs:
  node: circleci/node@5.2.0
jobs:
  sast-autofixer:
    docker:
      - image: cimg/base:stable
    steps:
      - checkout
      
      # Installing Node.js 18
      - node/install:
          node-version: '18'
          
      - run:
          name: "Prepare Environment for SAST and Mobb Steps"
          command: |
          
            # Extract the GitHub repo URL
            GITHUBURL=$(echo $CIRCLE_REPOSITORY_URL | sed 's/^git@github.com:/https:\/\/github.com\//;s/\.git$//')
            echo "Extracted GitHub URL: $GITHUBURL"
            echo "export GITHUBURL="$GITHUBURL"" >> $BASH_ENV
            
      - run:
          name: "SAST scan"
          command: |
            # Replace this step with your own SAST scanner
            npx snyk auth $SNYK_API_KEY
            npx snyk code test --sarif-file-output=report.json
            
      - run:
          name: "Mobb Autofixer"
          command: |
            
            # Run Mobb Autofixer against the report.json file generated in the previous step with Snyk SAST scan
            MOBBURL=$(npx mobbdev@latest analyze -f report.json -r $GITHUBURL --ref $CIRCLE_BRANCH --api-key $MOBB_API_KEY --ci)
            echo "Mobb URL: $MOBBURL"
            
            # Store the Mobb URL in a html file and save it as a CircleCI artifact
            echo "<html><body><a href="$MOBBURL">Click here for the Mobb URL</a></body></html>" > mobburl.html
            
            # (Optional Step) Publish the Mobb URL back to GitHub PR page. The script can be found in https://github.com/antonychiu2/mobb-circleci-integration/tree/main/.circleci
            ./.circleci/update_github_status.sh \
              "$GITHUB_PAT_SECRET" \
              "$CIRCLE_USERNAME" \
              "$CIRCLE_PROJECT_REPONAME" \
              "$CIRCLE_SHA1" \
              "success" \
              "$MOBBURL" \
              "Click on \\\"Details\\\" to access the Mobb Fix Link" \
              "Mobb Fix Link"
          when: on_fail
          
      - store_artifacts:
          path: mobburl.html
          destination: /MobbURL
          
      - store_artifacts:
          path: report.json
          destination: /Snyk Report
# Orchestrate jobs using workflows
workflows:
  test-workflow:
    jobs:
      - sast-autofixer
```

Click [here ](https://app.circleci.com/pipelines/github/antonychiu2/mobb-circleci-integration/90/workflows/d0737f24-5658-4c26-b97b-ed094fbd38f5/jobs/120)for a sample CircleCI job run.

Click [here ](https://github.com/antonychiu2/mobb-circleci-integration/tree/main)for a detailed sample implementation guide.

For a demonstration of how this integration works, you can visit the following YouTube video:

{% embed url="<https://www.youtube.com/watch?v=-YliDklzWSk>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mobb.ai/mobb-user-docs/ci-cd-integrations/circleci.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
