-
Notifications
You must be signed in to change notification settings - Fork 6
DevPIandJenkins
Jürgen Hermann edited this page Sep 2, 2014
·
8 revisions
TODO
- handling multiple concurrent jobs with different active indexes
- …
Add the shell snippet you'll find below to your default Jenkins environment, e.g. in your slave startup script.
This allows a job to call devpi_use my/repo
early on in a shell build step, which enables the following features;
-
devpi
is aliased to use a client dir local to the workspace and containing the config for the given repo, and thus isolate any devpi call against other jobs on the same slave. - The exported
PIP_INDEX_URL
can be passed topip --index-url
, or you just usedevpi install
instead (which internally does the same with the index URL from the config file in devpi's client dir).
Additionally, you should have default configuration files in the user account that runs the Jenkins slave, ideally with read-only permissions, so that jobs don't accidentally change those defaults and create race conditions and spurious job failures. These can be rolled out via your config management tool of choice.
# Jenkins environment definitions for "devpi"
export DEVPI_URL="http://devpi.example.com:31415/"
devpi_use() {
local index="${1:?You MUST provide an index name to devpi_use}"
local devpi_cfgdir="${WORKSPACE:?Envvar WORKSPACE is undefined, not in a Jenkins job?}/.devpi"
test -d "$devpi_cfgdir" || mkdir "$devpi_cfgdir"
alias devpi="$(which devpi) --clientdir "\'"$devpi_cfgdir"\'
export devpi
export PIP_INDEX_URL=$(devpi use --urls "${DEVPI_URL%/}/$index" | grep simpleindex | tr -d ' ' | cut -f2- -d:)
devpi use # dump status
}
test -z "$BASH_VERSION" && export devpi_use || export -f devpi_use
export PIP_INDEX_URL=$(devpi use --urls "${DEVPI_URL%/}/$index" | grep simpleindex | tr -d ' ' | cut -f2- ```