Files
dagu/examples
2022-11-20 19:39:17 +09:00
..
2022-11-20 19:39:17 +09:00
2022-11-20 15:45:07 +09:00
2022-08-19 22:02:15 +09:00
2022-09-20 17:55:12 +09:00
2022-11-20 15:45:07 +09:00
2022-11-20 19:39:17 +09:00
2022-11-20 15:45:07 +09:00

Examples

Printing Hello World

hello world

name: hello world
steps:
  - name: "hello"
    command: echo hello world
  - name: "done"
    command: echo done!
    depends:
      - "1"

Conditional step

conditional

params: foo
steps:
  - name: "step1"
    command: echo start
  - name: "foo"
    command: echo foo
    depends:
      - "step1"
    preconditions:
      - condition: "$1"
        expected: foo
  - name: "bar"
    command: echo bar
    depends:
      - "step1"
    preconditions:
      - condition: "$1"
        expected: bar

Writing to a file

steps:
  - name: write hello to '/tmp/hello.txt'
    command: echo hello
    stdout: /tmp/hello.txt

Passing output to the next step

output

steps:
  - name: pass 'hello'
    command: echo hello
    output: OUT1
  - name: output 'hello world'
    command: bash
    script: |
      echo $OUT1 world
    depends:
      - pass 'hello'

Runing Docker image

Example Log output

docker

steps:
  - name: deno_hello_world
    executor: 
      type: docker
      config:
        image: "denoland/deno:1.10.3"
        container:
          # See https://pkg.go.dev/github.com/docker/docker/api/types/container#Config
          volumes:
            /app:/app:
          env:
            - FOO=BAR
        host:
          # See https://pkg.go.dev/github.com/docker/docker/api/types/container#HostConfig
          autoRemove: true
    command: run https://examples.deno.land/hello-world.ts

Runing command via SSH

steps:
  - name: print ec2 instance id
    executor: 
      type: ssh
      config:
        user: ec2-user
        ip: "XXX.XXX.XXX.XXX"
        key: /Users/XXXXX/.ssh/prod-ec2instance-keypair.pem
        StrictHostKeyChecking: false
    command: ec2-metadata -i

Sending HTTP request

steps:
  - name: get fake json data
    executor: http
    command: GET https://jsonplaceholder.typicode.com/comments
    script: |
      {
        "timeout": 10,
        "headers": {},
        "query": {
          "postId": "1"
        },
        "body": ""
      }      

Sending Email Notification

Email example

sample

steps:
  - name: Sending Email on Finish or Error
    command: echo "hello world"

mailOn:
  failure: true
  success: true

smtp:
  host: "smtp.foo.bar"
  port: "587"
  username: "<username>"
  password: "<password>"
errorMail:
  from: "foo@bar.com"
  to: "foo@bar.com"
  prefix: "[Error]"
infoMail:
  from: "foo@bar.com"
  to: "foo@bar.com"
  prefix: "[Info]"

Customizing Signal on Stop

steps:
  - name: step1
    command: bash
    script: |
      for s in {1..64}; do trap "echo trap $s" $s; done
      sleep 60
    signalOnStop: "SIGINT"

How to contribute?

Feel free to contribute interesting examples in this page. Thanks!