Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

Commit

Permalink
new maven plugin jobs to build and deploy maven plugins to maven nexus
Browse files Browse the repository at this point in the history
This patch adds jobs to build maven plugins and deploy them
to the maven nexus repo at https://oss.sonatype.org

Closes-Bug: #1082812

Change-Id: I283d475ab18819391f282234b063522abbf09eda
  • Loading branch information
zaro0508 committed Dec 2, 2013
1 parent 2723fcd commit 9aef0e9
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 2 deletions.
2 changes: 2 additions & 0 deletions manifests/site.pp
Expand Up @@ -494,6 +494,8 @@
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'),
}
}

Expand Down
44 changes: 44 additions & 0 deletions 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" <pom.xml >${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
@@ -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'
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions modules/openstack_project/files/zuul/layout.yaml
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions modules/openstack_project/manifests/pypi_slave.pp
Expand Up @@ -52,4 +52,13 @@
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'],
}

}
1 change: 1 addition & 0 deletions modules/openstack_project/templates/mavencentral-curl.erb
@@ -0,0 +1 @@
user = "<%= mavencentral_username %>:<%= mavencentral_password %>"

0 comments on commit 9aef0e9

Please sign in to comment.