diff --git a/manifests/site.pp b/manifests/site.pp index bb522d4627..dcb17861a8 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -494,6 +494,8 @@ node 'pypi.slave.openstack.org' { jenkins_ssh_public_key => $openstack_project::jenkins_ssh_key, jenkinsci_username => hiera('jenkins_ci_org_user'), jenkinsci_password => hiera('jenkins_ci_org_password'), + mavencentral_username => hiera('mavencentral_org_user'), + mavencentral_password => hiera('mavencentral_org_password'), } } diff --git a/modules/jenkins/files/slave_scripts/mavencentral-upload.sh b/modules/jenkins/files/slave_scripts/mavencentral-upload.sh new file mode 100644 index 0000000000..cd162ecf65 --- /dev/null +++ b/modules/jenkins/files/slave_scripts/mavencentral-upload.sh @@ -0,0 +1,44 @@ +#!/bin/bash -x +# +# Copyright 2013 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 java packages to maven repositories + +PROJECT=$1 +VERSION=$2 +META_DATA_FILE=$3 +PLUGIN_FILE=$4 + +# Strip project name and extension leaving only the version. +VERSION=`echo ${PLUGIN_FILE} | sed -n "s/${PROJECT}-\(.*\).jar/\1/p"` + +# generate pom file with version info +POM_IN_ZIP=`unzip -Z -1 ${PLUGIN_FILE}|grep pom.xml` +unzip -o -j ${PLUGIN_FILE} ${POM_IN_ZIP} +sed "s/\${{project-version}}/${VERSION}/g" ${META_DATA_FILE} + +# deploy plugin artifacts from workspace to maven central repository +MAVEN_REPO="https://oss.sonatype.org/content/groups/public/maven" +MAVEN_REPO_CREDS="/home/jenkins/.mavencentral-curl" + +curl -X PUT \ + --config ${MAVEN_REPO_CREDS} \ + --data-binary @${META_DATA_FILE} \ + -i "${MAVEN_REPO}/${PROJECT}/${VERSION}/${META_DATA_FILE}" > /dev/null 2>&1 + +curl -X PUT \ + --config ${MAVEN_REPO_CREDS} \ + --data-binary @${PLUGIN_FILE} \ + -i "${MAVEN_REPO}/${PROJECT}/${VERSION}/${PLUGIN_FILE}" > /dev/null 2>&1 diff --git a/modules/openstack_project/files/jenkins_job_builder/config/maven-plugin-jobs.yaml b/modules/openstack_project/files/jenkins_job_builder/config/maven-plugin-jobs.yaml new file mode 100644 index 0000000000..a5b7a6040b --- /dev/null +++ b/modules/openstack_project/files/jenkins_job_builder/config/maven-plugin-jobs.yaml @@ -0,0 +1,89 @@ +# usig a freestyle project to work around jenkins bug: +# https://issues.jenkins-ci.org/browse/JENKINS-14193 + +- job-template: + name: 'gate-{name}-build' + node: precise + + wrappers: + - timeout: + timeout: 30 + fail: true + - timestamps + + builders: + - gerrit-git-prep + - shell: | + #!/bin/bash -xe + /usr/local/jenkins/slave_scripts/maven-properties.sh + - inject: + properties-file: maven.properties + - maven-target: + maven-version: Maven3 + pom: pom.xml + goals: 'clean package' + properties: + - project-version=${{PROJECT_VER}} + + publishers: + - console-log + +- job-template: + name: '{name}-localrepo-upload' + node: precise + + wrappers: + - timeout: + timeout: 30 + fail: true + - timestamps + + builders: + - gerrit-git-prep + - shell: | + #!/bin/bash -xe + /usr/local/jenkins/slave_scripts/maven-properties.sh + - inject: + properties-file: maven.properties + - maven-target: + maven-version: Maven3 + pom: pom.xml + goals: 'clean package' + properties: + - project-version=${{PROJECT_VER}} + + publishers: + - war: + site: 'tarballs.openstack.org' + warfile: 'target/{name}-${{PROJECT_VER}}.jar' + target: 'tarballs/ci/{name}' + - console-log + +- job-template: + name: '{name}-mavencentral-upload' + node: pypi + + builders: + - shell: | + #!/bin/bash -xe + TAG=`echo $ZUUL_REF | sed 's/^refs.tags.//'` + FILENAME_BIN="{name}-$TAG.jar" + + # copy plugin artifacts from tarballs to local workspace + rm -rf *.jar + curl -o $FILENAME_BIN http://{tarball-site}/ci/{name}/$FILENAME_BIN + + # deploy to maven repository + FILENAME_POM="{name}-$TAG.pom" + /usr/local/jenkins/slave_scripts/mavencentral-upload.sh {name} $TAG \ + $FILENAME_POM $FILENAME_BIN + + publishers: + - console-log + +- job-group: + name: maven-plugin-jobs + jobs: + - 'gate-{name}-build' + - '{name}-localrepo-upload' + - '{name}-mavencentral-upload' diff --git a/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml b/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml index d34a40d9d5..61ef56c3c0 100644 --- a/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml +++ b/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml @@ -362,6 +362,15 @@ jobs: - jenkins-plugin-jobs +- project: + name: clouddocs-maven-plugin + maven-group-id: com.rackspace.cloud.api + github-org: stackforge + node: precise + tarball-site: tarballs.openstack.org + + jobs: + - maven-plugin-jobs - project: name: zmq-event-publisher diff --git a/modules/openstack_project/files/zuul/layout.yaml b/modules/openstack_project/files/zuul/layout.yaml index b9a171b4cf..d9cf8973ae 100644 --- a/modules/openstack_project/files/zuul/layout.yaml +++ b/modules/openstack_project/files/zuul/layout.yaml @@ -1750,9 +1750,14 @@ projects: - name: stackforge/clouddocs-maven-plugin check: - - gate-noop + - gate-clouddocs-maven-plugin-build gate: - - gate-noop + - gate-clouddocs-maven-plugin-build + post: + - clouddocs-maven-plugin-localrepo-upload + release: + - clouddocs-maven-plugin-localrepo-upload: + - clouddocs-maven-plugin-mavencentral-upload - name: stackforge/congress check: diff --git a/modules/openstack_project/manifests/pypi_slave.pp b/modules/openstack_project/manifests/pypi_slave.pp index b43bf2a091..53ae559e09 100644 --- a/modules/openstack_project/manifests/pypi_slave.pp +++ b/modules/openstack_project/manifests/pypi_slave.pp @@ -52,4 +52,13 @@ class openstack_project::pypi_slave ( require => File['/home/jenkins'], } + file { '/home/jenkins/.mavencentral-curl': + ensure => present, + owner => 'jenkins', + group => 'jenkins', + mode => '0600', + content => template('openstack_project/mavencentral-curl.erb'), + require => File['/home/jenkins'], + } + } diff --git a/modules/openstack_project/templates/mavencentral-curl.erb b/modules/openstack_project/templates/mavencentral-curl.erb new file mode 100644 index 0000000000..6beba5bdf2 --- /dev/null +++ b/modules/openstack_project/templates/mavencentral-curl.erb @@ -0,0 +1 @@ +user = "<%= mavencentral_username %>:<%= mavencentral_password %>"