Skip to content

Instantly share code, notes, and snippets.

@jsuwo
Last active April 8, 2024 22:42
Show Gist options
  • Save jsuwo/9038610 to your computer and use it in GitHub Desktop.
Save jsuwo/9038610 to your computer and use it in GitHub Desktop.

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 {
}
@sghosh29
Copy link

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

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

@krishnadasari610
Copy link

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

@bhanuRanosys
Copy link

bhanuRanosys 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