How To Invoke A Jenkins Laid Upward From Assembla On Git Push

This tutorial volition endeavour to configure a jenkins chore to run when a git force is done on Assembla.

This tutorial assumes that your server is running inwards Ubuntu 12.04.2.

Requirements:

  1. You must convey an assembla trouble organisation human relationship amongst admin privilege.
  2. An external server amongst jenkins install
  3. Optional is artifactory
Assembla Configuration:
  1. Login to Assembla
  2. Click the Admin tab
  3. In the Tools section, click More inwards the far right side
  4. Find Webhook in addition to click add
  5. In Webhook, come inwards the next settings:
    1. Title=Anything
    2. Enabled=true
    3. Authentication type=basic
    4. External url=http:///git/notifyCommit?url=%{repository_url}&branch=%{branch}
    5. Http method=GET
    6. Context type=text/plain
    7. Post updates about=check "Code Commits"
    8. Click Save
Jenkins Configuration:
  1. Login to Jenkins in addition to brand certain yous convey the next plugins installed:
    1. Jenkins Artifactory Plugin
    2. Jenkins GIT Plugin
    3. SSH Agent Plugin
    4. SSH Credential Plugin
    5. Maven Project Plugin
  2. Configure credentials
    1. Go to Jenkins->Manage Jenkins->Manage Credentials
      1. If yous don't convey a domain yet, click Add Domain
      2. Scope=Global
      3. Username=jenkins
      4. Private Key=From the Jenkins master copy /.ssh
      5. Click advance tab in addition to come inwards your passphrase
Create a Job inwards Jenkins
  1. Click New Job
  2. Select Build a maven2/3 project
  3. Then fill upward up these fields, the residue tin forcefulness out endure filled amongst whatever values
    1. Source Code Management=GIT
    2. Repository URL=Copy your URL from Assembla, must endure inwards this format: git@git.assembla.com:YOUR_PROJECT.git
    3. Advance->Name=origin
    4. Branches to build=master
    5. Build Triggers (checked)
      1. Build whenever a SNAPSHOT dependency is built
      2. Poll SCM - piece of work out schedule patch blank
    6. Root pom=eg YOUR_PROJECT/pom.xml
    7. Goal options=clean install OR install
    8. Build Environment (checked)
      1. SSH agent (select jenkins)
    9. Post-build Actions
      1. Deploy artifacts to artifactory
        1. Select your artifactory server
        2. Target release=libs-release-local
        3. Target Snapshot=libs-snapshot-local
        4. Deploy maven artifacts (checked)
        5. Capture in addition to pose out hit information (checked)
Configure your SSH Agent
*NOTE: This script is non mine, I got it somewhere on google on OSX related forum unfortunately I forgot the link in addition to can't uncovering it now. Basically yous demand to add together a novel file for Ubuntu's jenkins user.
  1. Create a novel file inwards /.profile
    1. In bash type: half dozen /.profile
    2. Press :qw
    3. Press: Enter
  2. Paste the next lines (ssh-agent demand to endure laid earlier invoking ssh-add):
# Note:  /.ssh/environment should non endure used, equally it already has a dissimilar role inwards SSH.  env= /.ssh/agent.env  # Note: Don't bother checking SSH_AGENT_PID. It's non used #       yesteryear SSH itself, in addition to it mightiness fifty-fifty endure wrong #       (for example, when using agent-forwarding over SSH).  agent_is_running() {     if [ "$SSH_AUTH_SOCK" ]; thence         # ssh-add returns:         #   0 = agent running, has keys         #   1 = agent running, no keys         #   ii = agent non running         ssh-add -l >/dev/null 2>&1 || [ $? -eq 1 ]     else         faux     fi }  agent_has_keys() {     ssh-add -l >/dev/null 2>&1 }  agent_load_env() {     . "$env" >/dev/null }  agent_start() {     (umask 077; ssh-agent >"$env")     . "$env" >/dev/null }  if ! agent_is_running; thence     agent_load_env fi  if ! agent_is_running; thence     agent_start     ssh-add elif ! agent_has_keys; thence     ssh-add fi  unset env 

How to hit an SSH key:
  1. Create a key
  2. ssh-keygen -t dsa it volition endure created to /var/lib/jenkins/.ssh
  3. You volition demand to upload this telephone substitution to assembla
Git Configuration
  1. You demand to execute the ii lines below to configure git, e-mail must endure the e-mail yous job inwards assembla
  2. git config —global user.name “Your Name”
  3. git config —global user.email “email@email.com”
Testing
  1. In Ubuntu telephone yell upward execute: curl http:///git/notifyCommit?url=git@git.assembla.com:.git&branches=master
  2. Go to jenkins chore in addition to facial expression at Git Poll log, if something is wrong yous volition come across Common Problem #1
Common Problems
  1. Permission Error
    1. status code 128:
    2. stdout: 
    3. stderr: Permission denied (publickey).
    4. fatal: The remote destination hung upward unexpectedly
    5. Solution: Your telephone substitution is non properly setup either on jenkins or profile bash file
Next
Previous
Click here for Comments

0 komentar:

Please comment if there are any that need to be asked.