Add pypi-pre-commands to allow build steps before pypi publish
Change-Id: I1d564a5ef93b893f2767ee1dae9ccc60ab826bf2
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index b6e6ada..30cdacf 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -92,6 +92,11 @@
# in the job once testing is completed
pypi-index: 'testpypi'
+ # Commands to run within the root of the checked out repo before running
+ # the `python setup.py sdist` to generate the distribution.
+ # Primarily used for autogenerating code before publishing a repo
+ pypi-prep-commands: ''
+
# Name of the Docker repository (usually on DockerHub) that is the
# destination for images to be pushed to after building.
# Default is invalid - must be specified on every job.
diff --git a/jjb/pypi-publish.yaml b/jjb/pypi-publish.yaml
index b2076e9..0f6aca9 100644
--- a/jjb/pypi-publish.yaml
+++ b/jjb/pypi-publish.yaml
@@ -44,6 +44,7 @@
properties-content: |
PYPI_INDEX={pypi-index}
PYPI_MODULE_DIRS={pypi-module-dirs}
+ PYPI_PREP_COMMANDS={pypi-prep-commands}
- shell: !include-raw-escape: shell/pypi-publish.sh
diff --git a/jjb/shell/pypi-publish.sh b/jjb/shell/pypi-publish.sh
index 0f451cc..b7f3526 100755
--- a/jjb/shell/pypi-publish.sh
+++ b/jjb/shell/pypi-publish.sh
@@ -5,9 +5,10 @@
# Makes the following assumptions:
# - PyPI credentials are populated in ~/.pypirc
# - git repo is tagged with a SEMVER released version. If not, exit.
-# - If required, Environmental variables are set for:
-# PYPI_INDEX - name of PyPI index to use (see contents of ~/.pypirc)
+# - If required, Environmental variables can be set for:
+# PYPI_INDEX - name of PyPI index to use (see contents of ~/.pypirc for reference)
# PYPI_MODULE_DIRS - pipe-separated list of modules to be uploaded
+# PYPI_PREP_COMMANDS - commands to run (in root directory) to prepare for sdist
set -eu -o pipefail
@@ -18,6 +19,7 @@
# environmental vars
WORKSPACE=${WORKSPACE:-.}
+PYPI_PREP_COMMANDS=${PYPI_PREP_COMMANDS:-}
PYPI_INDEX=${PYPI_INDEX:-testpypi}
PYPI_MODULE_DIRS=${PYPI_MODULE_DIRS:-.}
@@ -32,6 +34,12 @@
exit 0
fi
+# Run commands if PYPI_PREP_COMMANDS if not null
+if [[ -n "$PYPI_PREP_COMMANDS" ]]
+then
+ $PYPI_PREP_COMMANDS
+fi
+
# iterate over $PYPI_MODULE_DIRS
# field separator is pipe character
IFS=$'|'
diff --git a/jjb/verify/voltha-protos.yaml b/jjb/verify/voltha-protos.yaml
index ada8bd0..0f193ab 100644
--- a/jjb/verify/voltha-protos.yaml
+++ b/jjb/verify/voltha-protos.yaml
@@ -11,6 +11,7 @@
- 'post-merge-voltha-protos-jobs':
branch-regexp: '{supported-branches-regexp}'
pypi-index: 'pypi'
+ pypi-prep-commands: 'make python-protos'
- job-group:
name: 'verify-voltha-protos-jobs'