steveforceit-blog
steveforceit-blog
Steve Force IT
3 posts
Forcing Information Technology to do stuff
Don't wanna be here? Send us removal request.
steveforceit-blog · 14 years ago
Text
Pretty Jenkins build notifications
The Jenkins Email-ext plug-in allows you to send an e-mail out when a build completes. You can customise the e-mail with your own text or HTML code.
The default message isn't much more than an "I just built something" notification. I want (1.) the build log as an attachment (so as not to clutter up the message body) and I want (2.) a visually appealing summary of the changes in the most recent build.
(1.) To get a the build log as an attachment, you have to copy the build log to the job workspace. As the build log is kept on the master Jenkins server, and the workspace is on the slave Jenkins client, I added an "Execute shell" step directly after the compilation step:
scp USERNAME@JENKINSSERVER:/var/lib/jenkins/jobs/$JOB_NAME/builds/$BUILD_ID/log build.log
This copies the log from the master to workspace on the slave, so you can enter "build.log" in the Email-ext plugin's Attachments field.
(2.) To get a visually appealing summary of the changes in a build, I cobbled together the following HTML code that can be pasted into the Email-ext's Default Content field for the message body (Jenkins > Manage Jenkins > Configure System > Extend E-mail Notification). Don't forget to set Default Content Type to HTML.
<div>     <table>         <tbody style="font-family: Helvetica, Arial; font-size: 13px">             <tr>                 <td style="color: black; font-size: 20px; font-weight: bold">                     <a href="${PROJECT_URL}">${PROJECT_NAME}</a> app, build <a href="${BUILD_URL}">${BUILD_NUMBER}</a>                 </td>             </tr>             <tr>                 <td class="infoMacro">                     Status: <b>${BUILD_STATUS}</b>                 </td>             </tr>             <tr>                 <td style="padding-bottom: 15px; border-bottom: 1px solid gray;">                     Cause: ${CAUSE}                 </td>             </tr>             <tr>                 <td>                     <div style="padding-top: 10px; padding-bottom: 10px; font-weight: bold">                         Changes:</div>                     <div style="padding-left: 30px; padding-bottom: 15px;">                             ${CHANGES, showPaths=true, format="<div><b>%a</b>: %r %p </div><div style=\"padding-left:30px;\"> — “<em>%m</em>”</div>",pathFormat="</div><div style=\"padding-left:30px;\">%p"}                     </div>                     <div style="padding-left: 30px; font-family: Monaco, Menlo, Courier; border-bottom: 1px solid gray;                         padding-bottom: 15px;">                     </div>                 </td>             </tr>             <tr>                 <td>                     <div style="padding-top: 10px; padding-bottom: 10px; font-weight: bold">                         Build log extract:</div>                     <div style="padding-left: 30px;">                         <div style="font-size: 10px; font-family: Monaco, Menlo, Courier; display: block;                             white-space: pre; overflow: auto; line-height: 1.4; border: 1px solid #ccc; background: #eeeeee;                             padding: 8px;">                             ${BUILD_LOG_REGEX, regex="^\\*\\* BUILD", linesBefore=0, linesAfter=10}</div>                     </div>                     <div style="padding-top: 15px">                     </div>                     <div style="border-top: 1px solid gray; padding-top: 10px; font-size: 10px; color: #999999;">                         (Links currently only work from within the iIntranet.)                     </div>                 </td>             </tr>         </tbody>     </table> </div>
With these in place I now receive attractive build notification e-mail messages after every build:
0 notes
steveforceit-blog · 14 years ago
Text
Initial push to a remote git repository
Cloning an empty remote git repository is easy enough. But pushing changes back to the remote repository requires a special command.  
The git clone command is easy enough to remember:
git clone ssh://[email protected]:12345/path/to/repo
Once the repository is checked out, you'll need to make your changes, git add to the local repository, git commit to check the files to the local repository, then run git push:
git push origin master
I need to find out more about what this means, and will update this post when I do.
4 notes · View notes
steveforceit-blog · 14 years ago
Text
Jenkins CI on Ubuntu 11.10
Setting up a Jenkins Continuous Integration (CI) server is pretty easy on Mac OS X or Windows. And thanks to the Ubuntu package manager, it's also easy to set up Jenkins on Ubuntu 11.10.
1.) Install Jenkins
Open the Ubuntu Package Manager and search for "Jenkins CI on Tomcat 6" (or just "jenkins-tomcat"). There are many Jenkins packages available, but this one will give us Jenkins running in a Java servlet container hosted by Tomcat. Don't worry about the relatively old version of Jenkins shown in the Ubuntu Package Manager (1.409.1). We will update Jenkins once it's installed.
Click Install.
When the installation is complete, you will find Tomcat 6 in /usr/share/tomcat6, the Jenkins WAR file is /usr/share/jenkins/jenkins.war, and the Jenkins configuration file is /var/lib/tomcat6/Catalina/localhost/jenkins.xml. You can access Jenkins with the URL http://localhost:8080/jenkins. Tomcat and Jenkins will start and stop automatically with the operating system.
2.) Update Jenkins
Open a Terminal window and type the following commands:
cd /usr/share/jenkins sudo mv jenkins.war jenkins.war_1-409-1.old sudo wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war
This backs up the original Jenkins archive, and downloads the latest version in its place.
3.) Restart Tomcat
In Terminal, type:
sudo /etc/init.d/tomcat6 restart
4.) Your new Jenkins CI server is ready to configure at http://localhost:8080/jenkins.
58 notes · View notes