Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Continuous Integration with Jenkins on Amazon EC2

Initial Setup

Fixing Locales in Ubuntu 13.04 on Amazon EC2

sudo apt-get install language-pack-en

Installing Jenkins

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
echo "deb http://pkg.jenkins-ci.org/debian binary/" | sudo tee -a /etc/apt/sources.list.d/jenkins.list
sudo apt-get update
sudo apt-get install jenkins

Installing and Configuring Apache

Installing Apache

sudo apt-get install apache2
sudo a2enmod proxy
sudo a2enmod proxy_http

/etc/apache2/sites-available/jenkins.conf

<VirtualHost *:80>
	ServerName HOSTNAME
	ProxyRequests Off
	<Proxy *>
		Order deny,allow
		Allow from all
	</Proxy>
	ProxyPreserveHost on
	ProxyPass / http://localhost:8080/
</VirtualHost>

Enabling jenkins.conf

sudo a2ensite jenkins
sudo service apache2 reload

Installing Java / Maven / Git

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer maven git-core
package ca.uwo.csd.cs2212.USERNAME;
public class BankAccount {
private double balance;
public BankAccount(double balance) {
this.balance = balance;
}
public double debit(double amount) {
if (balance < amount) {
amount = balance;
}
balance -= amount;
return amount;
}
}
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>ca.uwo.csd.cs2212.USERNAME</groupId>
<artifactId>USERNAME-lab5</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>7</maven.compiler.source>
<maven.compiler.target>7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
</project>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.4.201312101107</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
package ca.uwo.csd.cs2212.USERNAME;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
public class TestBankAccount {
}
@jchaitanya
Copy link

jchaitanya commented Feb 19, 2017

I stopped the instance and restarted it again but when i enter ec2 instance public dns in url page iam uable to access the jenkins page

@emreozkangit
Copy link

emreozkangit commented Oct 23, 2017

Me too jchaitanya

@apurvdeodhar
Copy link

apurvdeodhar commented Oct 28, 2017

SSH into your jenkins instance and check if jenkins is running perhaps it might be "Stopped"

Copy link

ghost commented Nov 8, 2017

Had the same problem. This is because the /etc/apache2/sites-available/jenkins.conf needs to be updated with the new hostname.

@victoremmanuel
Copy link

victoremmanuel commented Mar 19, 2018

Starting LSB: Start Jenkins at boot time...
ERROR: No Java executable found in current PATH: /bin:/usr/bin:/sbin:/usr/sbin
If you actually have java installed on the system make sure the executable is in the aforementione...ble path
jenkins.service: Control process exited, code=exited status=1
Failed to start LSB: Start Jenkins at boot time.
jenkins.service: Unit entered failed state.
jenkins.service: Failed with result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package jenkins (--configure):
subprocess installed post-installation script returned error exit status 1
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
jenkins

Pls help do i have to install java again or i have to set the env var

@victoremmanuel
Copy link

victoremmanuel commented Mar 20, 2018

[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.096 s
[INFO] Finished at: 2018-03-20T08:59:53+00:00
[INFO] Final Memory: 9M/21M
[INFO] ------------------------------------------------------------------------
Finished: SUCCESS

but no test cases ran.... pls help

@sghosh29
Copy link

sghosh29 commented May 23, 2018

I stopped the instance and restarted it again but when I enter ec2 instance public dns in url page I am unable to access the jenkins page. always showing "Apache2 Ubuntu Default Page" how to reslove this issue.

@shajay12
Copy link

shajay12 commented Sep 16, 2018

tell me the GITHUB url where all the Maven java project code is stored ??

@krishnadasari610
Copy link

krishnadasari610 commented Oct 7, 2019

when we try to enter systemctl reload apache2
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to reload 'apache2.service'.
Authenticating as: Ubuntu (ubuntu)
Password:
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
because of this I am unable to access the jenkins with "aws ec2 instance name:8080" in my local browser.

can anyone please guide me to resolve this issue

@AyaanRanosys
Copy link

AyaanRanosys commented Dec 26, 2019

Err:1 http://pkg.jenkins-ci.org/debian binary/ jenkins ...                               
  Connection failed
E: Failed to fetch http://pkg.jenkins-ci.org/debian/binary/jenkins_..._all.deb  Connection failed

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

If anyone facing the above error. Please use the following commands instead while installing Jenkins:

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

sudo rm  /etc/apt/sources.list.d/jenkins.list

echo "deb https://pkg.jenkins.io/debian-stable binary/" | sudo tee -a /etc/apt/sources.list.d/jenkins.list

sudo apt-get update

sudo apt-get install jenkins

If you still facing issues while installing Jenkins, you can directly download it from there website: https://pkg.jenkins.io/debian-stable/

Cheers!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment