:Required Parameters:
:pypi-repo: PyPI repository key in .pypirc configuration file;
- e.g., "staging" or "pypi".
+ e.g., "pypi-test" or "pypi".
lf-infra-tox-install
--------------------
Creates and uploads distribution files on merge of a patch set. Runs
tox, builds a source distribution and (optionally) a binary
distribution, and uploads the distribution(s) to a PyPI repository.
-This job should be configured to use a staging PyPI repository like
+This job should be configured to use a test PyPI repository like
testpypi.python.org, not a public release area like the global PyPI
repository. Like the verify job, this requires a setup.py file for
packaging the component.
export PATH="$PYENV_ROOT/bin:$PATH"
-Requires a .pypirc configuration file in the Jenkins builder home
-directory, an example appears next.
+Requires a .pypirc configuration file in the Jenkins builder home directory,
+an example appears next that uses API tokens. No repository is needed in the
+PyPI section.
.. code-block:: bash
[distutils] # this tells distutils what package indexes you can push to
- index-servers =
- staging
- pypi
+ index-servers = pypi-test pypi
- [staging]
- repository: https://testpypi.python.org/pypi
- username: your_username
- password: your_password
+ [pypi-test]
+ repository: https://test.pypi.org/legacy/
+ username: __token__
+ password: pypi-test-api-token-goes-here
[pypi]
- repository: https://pypi.python.org/pypi
- username: your_username
- password: your_password
+ username: __token__
+ password: pypi-api-token-goes-here
:Template Names:
:pre-build-script: Shell script to execute before the tox builder. For
example, install system prerequisites. (default: a shell comment)
:pypi-repo: Key for PyPI repository parameters in the .pypirc file.
- Merge jobs should use a server like testpypi.python.org. (default: staging)
+ Merge jobs should use a server like testpypi.python.org. (default: pypi-test)
:python-version: Python version to invoke pip install of tox-pyenv
(default: python3)
:stream: Keyword representing a release code-name.
--- /dev/null
+#!/usr/bin/no-execute
+
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2019 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+# A library of functions for LF/Jenkins bash scripts. In the general case, do
+# NOT set shell variables here. If you want to make a variable available,
+# provide a function that sets the variable: 'function lf_set_foo()
+# {foo=asdf;}'. Any scripts that need access to the variable can call the 'set'
+# function. This keeps the name-space polution to a minimum.
+
+################################################################################
+# Functions
+################################################################################
+
+# Execute pip from 'user' venv
+function lf-pip() { /home/jenkins/.local/bin/pip "$@" ; }
+
+# Echo all arguments to stderr
+function lf-echoerr() { echo "$@" 1>&2; }
+
+# Function to safely evaluate booleans
+# If the boolean equal '' it is an Fatal Error
+# Note the case of boolean will be ignored (always mapped to lower-case)
+function lf-boolean()
+{
+ if [[ $# != 1 ]]; then
+ echo "lf-boolean(): Missing boolean operand"
+ exit 1
+ fi
+ local bool
+ bool=$(echo "$1" | tr '[:upper:]' '[:lower:]')
+ if [[ -z $bool ]] ; then
+ # Output script name & line number of call to function
+ lf-echoerr "ERROR: $(basename $0) line: ${BASH_LINENO[0]} : A boolean cannot be a empty string" >&2
+ exit 1
+ fi
+ $bool
+}
+
+# Function to activate a Python Virtual Environment
+# Just validate the path and add 'bin' to the path
+function lf-activate()
+{
+ if [[ $# != 1 ]]; then
+ echo "lf-activate(): Missing path operand"
+ exit 1
+ fi
+ local venv_path=$1
+ # Validate the path to a VENV
+ if [[ ! -d $venv_path/bin ]]; then
+ lf-echoerr "ERROR: Is '$venv_path' a Python Environment ?"
+ return 1
+ fi
+ PATH=$venv_path/bin:$PATH
+}
+
+################################################################################
+# Functions that assign Variables
+################################################################################
+
+# Although these variables are 'shell' variables, they need to be upper-case so
+# 'shellcheck' does check for 'used-before-set' when they are referenced. So if
+# forget to 'source' this file, you will get a 'run-time' error (if you have -u
+# set), otherwise you will get "MAVEN_OPIONS=''.
+
+function lf-set-maven-options()
+{
+ # shellcheck disable=SC2034 # Disable 'unused-variable' check
+ MAVEN_OPTIONS=$(echo --show-version --batch-mode -Djenkins \
+ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
+ -Dmaven.repo.local=/tmp/r -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r)
+}