diff --git a/modules/jenkins/files/slave_scripts/pypi-extract-metadata.py b/modules/jenkins/files/slave_scripts/pypi-extract-metadata.py new file mode 100644 index 0000000000..eac21fdda4 --- /dev/null +++ b/modules/jenkins/files/slave_scripts/pypi-extract-metadata.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +# +# Copyright 2012 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Extract package info metadata for use by curl. + +import pkginfo +import sys + +if len(sys.argv) < 3: + exit() + +info = pkginfo.SDist(sys.argv[1]) +curl_config = open(sys.argv[2], 'w') + +meta_items = { + 'metadata_version': info.metadata_version, + 'summary': info.summary, + 'home_page': info.home_page, + 'author': info.author, + 'author_email': info.author_email, + 'license': info.license, + 'description': info.description, + 'keywords': info.keywords, + 'platform': info.platforms, + 'classifiers': info.classifiers, + 'download_url': info.download_url, + 'provides': info.provides, + 'requires': info.requires, + 'obsoletes': info.obsoletes, +} + +for key, value in meta_items.items(): + if not value: + continue + if not isinstance(value, list): + value = [value] + for v in value: + curl_config.write('form = "%s=%s"\n' % (key, v)) + +curl_config.write('\n') +curl_config.close() diff --git a/modules/jenkins/files/slave_scripts/pypi-upload.sh b/modules/jenkins/files/slave_scripts/pypi-upload.sh index e98fae65bf..e7df2dfcaf 100755 --- a/modules/jenkins/files/slave_scripts/pypi-upload.sh +++ b/modules/jenkins/files/slave_scripts/pypi-upload.sh @@ -1,4 +1,20 @@ #!/bin/bash +# +# Copyright 2012 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Upload python sdist to pypi with Curl. PROJECT=$1 @@ -7,7 +23,10 @@ FILENAME=`ls ${PROJECT}*.tar.gz` VERSION=`echo ${FILENAME} | sed -n "s/${PROJECT}-\(.*\).tar.gz/\1/p"` MD5_DIGEST=`md5sum ${FILENAME} | cut -d' ' -f1` +/usr/local/jenkins/slave_scripts/pypi-extract-metadata.py $FILENAME metadata.curl + curl --config /home/jenkins/.pypicurl \ + --config metadata.curl \ -F "filetype=sdist" \ -F "content=@${FILENAME};filename=${FILENAME}" \ -F ":action=file_upload" \ diff --git a/modules/openstack_project/files/jenkins_job_builder/config/pypi-jobs.yaml b/modules/openstack_project/files/jenkins_job_builder/config/pypi-jobs.yaml index f01178492d..bde6c51eb4 100644 --- a/modules/openstack_project/files/jenkins_job_builder/config/pypi-jobs.yaml +++ b/modules/openstack_project/files/jenkins_job_builder/config/pypi-jobs.yaml @@ -69,14 +69,17 @@ node: pypi builders: + - shell: | + if [ -e dist ] + then + rm -rf dist + fi - copyartifact: project: '{name}-pypi-sdist' filter: 'dist/{name}*.tar.gz' - shell: | cd dist /usr/local/jenkins/slave_scripts/pypi-upload.sh {name} - # Remove copied artifact - rm -rf {name}*.tar.gz publishers: - console-log-post diff --git a/modules/openstack_project/manifests/pypi_slave.pp b/modules/openstack_project/manifests/pypi_slave.pp index f7c2e008c5..904514da8e 100644 --- a/modules/openstack_project/manifests/pypi_slave.pp +++ b/modules/openstack_project/manifests/pypi_slave.pp @@ -1,8 +1,31 @@ +# Copyright 2012 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Class to install dependencies for uploading python packages to pypi. +# class openstack_project::pypi_slave ( pypi_password, pypi_username = 'openstackci' ) { include openstack_project::slave + include pip + + package { 'pkginfo': + ensure => present, + provider => 'pip', + require => Class['pip'], + } file { '/home/jenkins/.pypicurl': ensure => present,