Monday 29 December 2014

Configure bamboo with NEXUS - Sonatype

I use for configuration bamboo 5.7.1 and all configuration will be done from script - I not use plugins

First I prepare build project consists from 2 stages
- one for prepare package - for example zip file
- two for update package to repository - NEXUS

When I have zip file to upload to NEXUS I use NEXUS api to upload file
#use timestamp to versioning
VERSION=`echo "${bamboo.buildTimeStamp}" | sed 's/:/-/g' | cut -f 1 -d "."`
#uploadcurl -v \
   -F "r=releases" \ 
   -F "g=pl.company.sql" \ 
   -F "hasPom=false" \
   -F "a=db" \
   -F "c=${bamboo.buildResultKey}" \
   -F "p=zip" \    -F "v=$VERSION" \
   -F "file=@./$f" \
   -u  deployment:${bamboo.nexuspassword}\ 
   http://service/nexus/service/local/artifact/maven/content
important is use classifier

or You can use MAVEN

Second - download script for deployment project

#Fix mapping between buildResultKey
CLASS=`echo ${bamboo.buildResultKey} | sed 's/-/-RDP-/2'`
-For more information see post below and continue
#find package by classifier
VERSION=`curl -u  deployment:${bamboo.nexuspassword} "http://service/nexus/service/local/lucene/search?g=$GROUP&a=$ARTIFACT&c=$CLASS&r=$REPO" | sed -n 's|<version>\(.*\)</version>|\1|p' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//'`

#Download by wget
wget -O db-sprint.zip --user deployment --password=${bamboo.nexuspassword} "http://service/nexus/service/local/artifact/maven/content?r=$REPO&g=$GROUP&a=$ARTIFACT&v=$VERSION&p=zip&c=$CLASS"



Configure mapping between build project and deployment project in Bamboo

Atlassian Bamboo don't have formal mapping between build project and deployment project but you can use buildResultKey - it constain number of build which is constant.

I create build plan and deployment plan in deployment plan set to update buildResultKey to be correct for deployment plan

echo ${bamboo.buildResultKey} | sed 's/-/-JOB1-/2'

You shoud list buildResultKey variable in build project and deployment project and check difference - for me it is JOB1