Coder Social home page Coder Social logo

ganezasan / auto-cancel-workflow-orb Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 2.0 10 KB

This is a CircleCI orb for canceling all jobs in a workflow when one of a job in the workflow is failed.

Home Page: https://circleci.com/orbs/registry/orb/ganezasan/auto-cancel-workflow

circleci circleci-orbs orbs

auto-cancel-workflow-orb's Introduction

  • ๐Ÿ‘‹ Hi, Iโ€™m @ganezasan
  • ๐Ÿ‘€ Iโ€™m interested in Automation
  • ๐ŸŒฑ Iโ€™m currently learning about Jest which is JavaScript testing framework
  • ๐Ÿ’ž๏ธ Iโ€™m looking to collaborate on something connect to my lifestyle
  • ๐Ÿ“ซ How to reach me on twitter @ganezasan

auto-cancel-workflow-orb's People

Watchers

 avatar  avatar

Forkers

mix3 makarono

auto-cancel-workflow-orb's Issues

Use small resource class

Suggest updating the executor to use a small resource class. There's no point wasting $ on anything else for this.

executors:
  default:
    docker:
      - image: circleci/node:latest

Alternatively, maybe make it configurable via a param. Although I'm not sure if that's possible.

NPE in job

Not sure how else to communicate with you so posting this issue here.

I have this job added to my config like thi s

      - auto-cancel-workflow/auto-cancel:
          context: circle_ci_context
          interval_seconds: 30

The circle_ci_context has CIRCLE_TOKEN in it. Now when this job runs, I get this error

#!/bin/bash -eo pipefail
while true; do
  json=$(curl -s -H 'Accept: application/json' -X GET https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/job?circle-token=${CIRCLE_TOKEN})
  is_failed=$(echo $json | jq '.items | map(select(.name | contains("auto-cancel") | not)) | any(.status == "failed")')
  is_pending=$(echo $json | jq '.items | map(select(.name | contains("auto-cancel") | not)) | any(.status == "running")')

  if [ "$is_failed" == "true" ]; then
    echo "Cancel workflow"
    curl -s -H 'Accept: application/json' -X POST https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/cancel?circle-token=${CIRCLE_TOKEN}
    exit 0
  elif [ "$is_pending" == "false" ]; then
    echo "other jobs are finished"
    echo $json | jq '.items | map(select(.name | contains("auto-cancel") | not))'
    exit 0
  else
    echo "waiting for other jobs"
  fi
  sleep 30
done

jq: error (at <stdin>:1): Cannot iterate over null (null)

Exited with code exit status 5

CircleCI received exit code 5

Why is it failing? How can i fix it?

Update:

I tried passing in token explicitly, and that too failed with same error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.