Examples

About 3 min

Examples

This section contains examples of how to use the Pipelines SDK.

Build the documentation site

This example shows how to build the documentation site for the Nosana SDK. Let's quickly go through it.

At the top the nosana.yml file, we have the nosana section. This is used to configure the pipeline itself. The description is used to identify the pipeline in the Nosana network. The storage is used to configure the backend storage service that will be used to store the data that is generated by the pipeline. For now only IPFS is supported.

In the global section we have the image that will be used to run the pipeline. For this pipeline we are using the node:16 image. Take notice that the whole URI is required, not just the image name. This pipeline will be triggered on the following branches: main and develop.

The jobs section is used to configure the individual jobs that will be executed in the pipeline. The image used for these jobs is already defined in the global section, so there is no need to define it again. For this example there are two jobs, install and generate. The basic gist of it is that the install job will install the dependencies, and the generate job will generate the documentation site.

For illustration purposes the resources 🡪 artifact pattern is shown to show how to use artifacts between jobs. This is not required for this pipeline, but it is a good example of how to use artifacts.

Last but not least, the artifacts generated by the pipeline called dist will be stored in storage to be used later for you purposes

# .nosana-ci.yml
nosana:
    description: Build Nosana Documentation
    storage: IPFS

global:
    image: registry.hub.docker.com/library/node:16

    # Git, trigger on these branches
    trigger:
        branch:
            - main
            - develop

    # Environment variables
    environment:
        APP_ENV: production # comment here about this var

    # Allow pipeline to stop if one job fails
    allow_failure: true # default: false

jobs:

    # Install dependencies
    - name: install
      commands:
        - npm ci
      artifacts: # artifact for the next job
        - name: node_modules
          path: ./node_modules/

    # Lint and generate docs.
    - name: generate
      commands:
          - npm run eslint
          - npm run prettier
          - npm run generate
      resources: # artifact from previous job
        - name: node_modules
          path: ./node_modules/
      artifacts: # artifact for deployment
          - name: dist
            path: ./dist/
Last update: