# Kudu
Kudu is a command-line tool that allows you to pull and push your files from and to Pitcher Admin. Using Kudu, you can easily make changes to files and deploy them to Pitcher Admin.
# Installation
You can install kudu
with the command below:
pip3 install kudu
Then you can run in the command line as:
kudu
When called without arguments, it will output the Options and Commands that kudu accepts.
# Options
Kudu needs a Pitcher Admin username
/password
or a Pitcher API token
to access your instance. There are multiple ways to provide kudu credentials.
# Option 1 (recommended)
- Create a file named
.kudu.yml
in your home directory - Add provided username and password in this file as shown below
username: [USERNAME]
password: [PASSWORD]
# or
token: [TOKEN]
# Option 2
You can also provide credentials directly through the cli when you execute a kudu command.
kudu -u [USERNAME] -p [PASSWORD] [command]
# or
kudu -t [TOKEN] [command]
# Option 3
You can also have KUDU_USERNAME
/KUDU_PASSWORD
or KUDU_TOKEN
as an environment variable.
export KUDU_USERNAME=[USERNAME]
export KUDU_PASSWORD=[PASSWORD]
# or
export KUDU_TOKEN=[TOKEN]
# Commands
# init
This command will prompt you whether you want to create a new file.
- If you respond yes, it will ask your instance id and create a new zip file with Pitcher folder template in that instance.
- If you respond no, it will ask your file id and bring that file to your local.
kudu init
# pull
This command will pull the file with file id FILEID
from Pitcher Admin to your local. You can provide a path
for the file to be placed to, otherwise it will be placed to your present working directory.
kudu pull -f [FILEID]
# or
kudu pull —f [FILEID] —p [PATH]
# push
This command will push the file you have provided in path
argument to the existing file with file id FILEID on Pitcher Admin. If the path
argument is a directory, it will be zipped before sending over. If you don’t provide a path
, your current directory will be zipped and sent over.
kudu push —f [FILEID] —p [PATH]
# link
This command will copy the contents in your current working directory to PITCHER_FOLDERS_PATH
as the file with FILEID
and it will watch for the changes you make and automatically apply them to Pitcher folders directory.
kudu link —f [FILEID] —pf [PITCHER_FOLDERS_PATH]
NOTE
When applicable, you may use watch
command with npm instead of this command, covered in Debugging sections for iOS, Windows or Android.
# Github Actions
You can use Kudu in your Github Actions (opens new window) to automatically deploy Pitcher files from your Github repository.
# One Repo - One File
If your repository root folder contains contents of a zip file in Pitcher, you can use the following snippet in a .yml file under .github/workflows
folder in your repository, to deploy your changes to a zip/presentation type Pitcher file when pushed to main branch.
.github/workflows/deploy.yml
name: PITCHER Deployment
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip3 install kudu
- run: kudu push -f [FILE_ID]; echo 'deployed'
env:
KUDU_USERNAME: ${{ secrets.KUDU_USERNAME }}
KUDU_PASSWORD: ${{ secrets.KUDU_PASSWORD }}
NOTE
This example uses Github Secrets (opens new window) to store the username/password securely. You can set up Github secrets in your repository settings on Github.
# One Repo - Multiple Files
In some cases, you may want to use one repository for multiple Pitcher files and deploy only the specific ones that were changed in your push.
You may use the following yml file with a 3rd party Github action get-changed-files (opens new window), in conjunction with a bash script that gets the output of changed files as its argument.
.github/workflows/deploy.yml
name: PITCHER Multiple File Deployment
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: getchangedfiles
uses: jitterbit/get-changed-files@v1
with:
format: 'csv'
- run: pip3 install kudu
- run: bash deploy.sh ${{ steps.getchangedfiles.outputs.all }}
env:
KUDU_USERNAME: ${{ secrets.KUDU_USERNAME }}
KUDU_PASSWORD: ${{ secrets.KUDU_PASSWORD }}
deploy.sh
#!/bin/bash
set -e
# File / folder names in repository
names=("interactive_1" "interactive_2")
# File IDs on Pitcher
file_ids=("interactive_1_file_id" "interactive_2_file_id")
# Looping over names
for ((i=0;i<${#names[@]};++i)); do
# Matching the csv output of jitterbit/get-changed-files@v1 action
if [[ "$*" == ${names[i]}* || "$*" == *,${names[i]}* ]]
then
printf "Deploying %s to %s\n" "${names[i]}" "${file_ids[i]}"
kudu push -p ${names[i]} -f ${file_ids[i]}
fi
done