For years, I've had a many-step process for releasing Maven artifacts to the JBoss Nexus, which has made me reticent to do frequent releases due to the heavily manual process.
- Commit a change to the artifact's pom, replacing version x.y.z-SNAPSHOT with x.y.z
- Build the artifact in Jenkins (often triggered automatically via Github hooks) and deploy it to staging Nexus instance using server credentials in Jenkins
- Log into Nexus
- Browse for the Staging repos
- Sort the list by most recently updated
- Look for the "Implicitly created (auto staging)." entries
- For each entry, select the Content tab and drill down to see if that entry is the correct one (could be another job or person's staging bits)
- If the entry is correct, click the Close button and enter a description; if not, check the next one in the list until you find the correct one
- Click Refresh button
- Click the Release button
- Browse Nexus to verify the artifact is deployed
But no more!
With the nexus-staging-maven-plugin, I can simplify that process by adding more Maven steps the job.
- Commit a change to the artifact's pom, replacing version x.y.z-SNAPSHOT with x.y.z
- Build the artifact in Jenkins (often triggered automatically via Github hooks) and deploy it to production Nexus instance using server credentials in Jenkins
- Browse Nexus to verify the artifact is deployed
So, how do you enable this?
- Ensure you have all the correct metadata configured in your pom: description, URL, license, developers, SCM, issueManagement, etc.
- Add nexus-staging-maven-plugin to your pom
- Perform three steps in Jenkins
That's it!
Or, to enable this selectively for only releases (but not SNAPSHOTS):
pom=${WORKSPACE}/path/to/pom.xml pomVersion=$(grep "" ${pom} | head -1 | sed -e "s#.*\(.\+\).*#\1#") MVN="/path/to/maven3/bin/mvn -Dmaven.repo.local=${WORKSPACE}/.repository/" if [[ ${pomVersion} == *"-SNAPSHOT" ]]; then ${MVN} deploy else ${MVN} clean deploy -DskipRemoteStaging=true -f ${pom} \ -DstagingDescription="[${JOB_NAME} ${BUILD_TIMESTAMP} ${BUILD_NUMBER}] :: ${pomVersion} :: deploy to local" ${MVN} nexus-staging:deploy-staged -f ${pom} \ -DstagingDescription="[${JOB_NAME} ${BUILD_TIMESTAMP} ${BUILD_NUMBER}] :: ${pomVersion} :: deploy to stage + close" ${MVN} nexus-staging:release -f ${pom} \ -DstagingDescription="[${JOB_NAME} ${BUILD_TIMESTAMP} ${BUILD_NUMBER}] :: ${pomVersion} :: release" fi
0 comments:
Post a Comment