Is it possible to trigger a workflow with custom parameters via an API call?

Is it possible to parse through unique parameters with triggering a workflow via the api? If so, can someone point me in the right direction, if not, any other suggestions? In the example below, it’s $PACKAGE_ID

We white label our app for many customers so effectively we make use of the same code base and pass a parameter that than go and fetch branding, configs, etc for each of our tenant apps. We don’t always want to update all of our apps at the same time and therefore use an api call to choose which apps to update based on their $PACKAGE_ID.

In the past we were doing this with jobs. But since we’ve moved to React-Native we now use workflows because of the shared node resource.

Any help will be greatly appreciated.

machine:
  ruby:
    version: "2.3"
version: 2
jobs:
  node:
    working_directory: ~/hello
    docker:
      - image: circleci/node:8

    steps:
      - checkout

      - restore_cache:
          key: node-v1-{{ checksum "package.json" }}-{{ arch }}

      - run: npm install

      - save_cache:
          key: node-v1-{{ checksum "package.json" }}-{{ arch }}
          paths:
              - node_modules

      - persist_to_workspace:
          root: ~/hello
          paths:
              - node_modules

  android:
    working_directory: ~/hello/android
    docker:
      - image: circleci/android:api-28-node8-alpha
    steps:
      - checkout:
          path: ~/hello

      - attach_workspace:
          at: ~/hello
          
      - restore_cache:
          key: bundle-v1-{{ checksum "Gemfile.lock" }}-{{ arch }}

      - run:
          name: Configure Bundler
          command: |
            echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
            source $BASH_ENV
            gem install bundler
      
      - run: bundle install

      - run: curl -sL firebase.tools | bash

      - save_cache:
          key: bundle-v1-{{ checksum "Gemfile.lock" }}-{{ arch }}
          paths:
            - vendor/bundle

      - run: yes | sdkmanager --licenses || exit 0
      - run: yes | sdkmanager --update || exit 0

      - run:
          command: bundle exec fastlane prod package_id:$PACKAGE_ID
      
  ios:
    macos:
      xcode: "11.3.0"
    working_directory: ~/hello/ios
    
    environment:
      FASTLANE_PASSWORD: Enlight*11
    
    # use a --login shell so our "set Ruby version" command gets picked up for later steps
    shell: /bin/bash --login -o pipefail

    steps:
      - checkout:
          path: ~/hello

      - attach_workspace:
          at: ~/hello
      
      - run: bundle install --path vendor/bundle
      - run: pod install
      - run: npm i -s react-native-cli
      - run: curl -sL firebase.tools | bash

      - save_cache:
          key: bundle-v1-{{ checksum "Gemfile.lock" }}-{{ arch }}
          paths:
            - vendor/bundle

      - run:
          command: bundle exec fastlane prod package_id:$PACKAGE_ID
          # no_output_timeout: 45m

workflows:
  version: 2
  node-android-ios:
    jobs:
      - node
      - android-prod:
          requires:
            - node
          filters:
            branches:
              ignore: /.*/
      - ios-prod:
          requires:
            - node
          filters:
            branches:
              ignore: /.*/

Heya @gregk8288! It’s entirely possible to do this through the use of pipeline parameters in our v2 API preview. Our docs are available here https://github.com/CircleCI-Public/api-preview-docs/blob/master/docs/pipeline-parameters.md :slight_smile:

Wonderful! Thank you!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.