This tutorial assumes that your server is running inwards Ubuntu 12.04.2.
Requirements:
- You must convey an assembla trouble organisation human relationship amongst admin privilege.
- An external server amongst jenkins install
- Optional is artifactory
Assembla Configuration:
- Login to Assembla
- Click the Admin tab
- In the Tools section, click More inwards the far right side
- Find Webhook in addition to click add
- In Webhook, come inwards the next settings:
- Title=Anything
- Enabled=true
- Authentication type=basic
- External url=http://
/git/notifyCommit?url=%{repository_url}&branch=%{branch} - Http method=GET
- Context type=text/plain
- Post updates about=check "Code Commits"
- Click Save
Jenkins Configuration:
- Login to Jenkins in addition to brand certain yous convey the next plugins installed:
- Jenkins Artifactory Plugin
- Jenkins GIT Plugin
- SSH Agent Plugin
- SSH Credential Plugin
- Maven Project Plugin
- Configure credentials
- Go to Jenkins->Manage Jenkins->Manage Credentials
- If yous don't convey a domain yet, click Add Domain
- Scope=Global
- Username=jenkins
- Private Key=From the Jenkins master copy /.ssh
- Click advance tab in addition to come inwards your passphrase
Create a Job inwards Jenkins
- Click New Job
- Select Build a maven2/3 project
- Then fill upward up these fields, the residue tin forcefulness out endure filled amongst whatever values
- Source Code Management=GIT
- Repository URL=Copy your URL from Assembla, must endure inwards this format: git@git.assembla.com:YOUR_PROJECT.git
- Advance->Name=origin
- Branches to build=master
- Build Triggers (checked)
- Build whenever a SNAPSHOT dependency is built
- Poll SCM - piece of work out schedule patch blank
- Root pom=eg YOUR_PROJECT/pom.xml
- Goal options=clean install OR install
- Build Environment (checked)
- SSH agent (select jenkins)
- Post-build Actions
- Deploy artifacts to artifactory
- Select your artifactory server
- Target release=libs-release-local
- Target Snapshot=libs-snapshot-local
- Deploy maven artifacts (checked)
- 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.
- Create a novel file inwards /.profile
- In bash type: half dozen /.profile
- Press :qw
- Press: Enter
- 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:
- Create a key
- ssh-keygen -t dsa it volition endure created to /var/lib/jenkins/.ssh
- You volition demand to upload this telephone substitution to assembla
Git Configuration
- You demand to execute the ii lines below to configure git, e-mail must endure the e-mail yous job inwards assembla
- git config —global user.name “Your Name”
- git config —global user.email “email@email.com”
Testing
- In Ubuntu telephone yell upward execute: curl http://
/git/notifyCommit?url=git@git.assembla.com: .git&branches=master - 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
- Permission Error
- status code 128:
- stdout:
- stderr: Permission denied (publickey).
- fatal: The remote destination hung upward unexpectedly
- Solution: Your telephone substitution is non properly setup either on jenkins or profile bash file
0 komentar:
Please comment if there are any that need to be asked.