[JAVA] Easily set up a Jenkins server on AWS using Bitnami's AMI

Introduction

Purpose

Create a Jenkins server for batch processing schedule execution as well as CI. If you get used to it, you should be able to make it in less than 20 minutes.

What you can do with this article

What is Bitnami

They distribute packages that set the software environment construction in a nice way. There are various package formats such as images for containers and cloud environments and for on-premise.

We make it possible for anyone to quickly deploy software on the platform of their choice, from native installers to cloud images to containers.

See below for more information.

https://bitnami.com/learn_more

Reference information

Use the following packages. The latest version at the time of writing (2017/06/28) is "2.46.2-0 on Ubuntu 14.04.3".

Jenkins powered by Bitnami https://aws.amazon.com/marketplace/pp/B00NNZUF3Q

document https://docs.bitnami.com/aws/apps/jenkins/

Documents> ID / PASSWORD https://bitnami.com/stack/jenkins/cloud/aws

Community (search here if you have any questions) https://community.bitnami.com/c/jenkins

procedure

Create an EC2 instance from an AMI

  1. After transitioning to the following URL on the AWS Marketplace, select "Continue" on the right side of the screen.

Jenkins powered by Bitnami https://aws.amazon.com/marketplace/pp/B00NNZUF3Q

At this time, if you have not logged in to AWS, you will be prompted to log in, so log in.

  1. Select "Manual Launch" on the "Launch on EC2: Jenkins powered by Bitnami" screen.

I choose Manual Launch because it's created from the familiar AWS Console (for personal reasons)

  1. Select "Launch with EC2 Console" from Launch> AMI IDs> Asia Pacific (Tokyo)

  2. Create an EC2 instance

Although omitted, the default settings are basically OK. Use the key pair created here to log in to ssh later. Open ports 80 and 22. Apply some IP restrictions.

Log in to Jenkins ~ Initial settings

After starting the instance, access port 80 of the IP assigned to the instance from the browser. The Jenkins login screen will be displayed, so enter your ID and password.

ID: user
PASSWORD: (Check from the system log of the EC2 instance. Refer to the following URL.)

(Reference) How To Find Application Credentials? https://docs.bitnami.com/aws/faq/#find_credentials

After logging in, follow the on-screen instructions and install the recommended plug-ins unless you are particular about it.

Change server time to Japan Standard Time (JST)

  1. Ssh login to the server

The user is bitnami. Enter the public key and address as appropriate.

ssh -i path/to/keypair.pem bitnami@IPAddress
  1. Change to Japan Standard Time (JST) with the following command
echo "Asia/Tokyo" | sudo tee /etc/timezone
sudo dpkg-reconfigure --frontend noninteractive tzdata

(Reference) Ubuntu Time Management https://help.ubuntu.com/community/UbuntuTime

  1. Restart Jenkins
sudo /opt/bitnami/ctlscript.sh restart

(Reference) How To Start Or Stop The Services? https://docs.bitnami.com/aws/apps/jenkins/

GitHub integration

Implement with reference to the following documents.

How To Start With Git And Jenkins? https://docs.bitnami.com/aws/apps/jenkins/#how-to-start-with-git-and-jenkins

Since it is necessary to generate the ssh authentication key in advance and correspond to the Github account after generation, carry out by referring to the following.

ssh authentication key generation

Execute the following command as a bitnami user to generate an ssh authentication key for the tomcat user.

ssh-keygen -t rsa

At this time, you will be asked where to generate it, so set it to /home/tomcat/.ssh/id_rsa. After that, enter without input.

Add ssh authorization key to your GitHub account

Add the entire contents of /home/tomcat/.ssh/id_rsa.pem to your Github account by referring to the following.

Adding a new SSH key to your GitHub account https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

Change permissions on /opt/bitnami/.gradle

Due to a bitnami bug, there is an error in the permission settings of the directory used by gradle. Change the owner of /opt/bitnami/.gradle to tomcat as follows.

sudo chwon tomcat:tomcat /opt/bitnami/.gradle

https://community.bitnami.com/t/gradle-user-home-opt-bitnami-gradle/40717

Install JDK for build

Install any JDK from Jenkins Management> Global Tool Configuration> JDK. You need an Oracle account, so if you don't have one, it's free, so create one.

スクリーンショット 2017-06-29 0.28.49.png

The JDK installed here will be used when building the job. If you install more than one, you can select the JDK to use on the setting screen of each job.

Verification

Make sure you can build the Gradle project in your private repository on GitHub. If you have already created it, follow the steps below to verify that the build is successful.

  1. Select "Create new job"

  2. Enter an appropriate job name in the input field, select "Build Freestyle Project", and press the OK button.

  3. After entering the following contents on the job setting screen, press the save button.

** Source Code Control> Repository URL **

[email protected]:USERNAME/REPONAME.git

** Build> Invoke Gradle script> Use Gradle Wrapper **

  1. Press the "Run Build" button and confirm that the build is successful

Recommended Posts

Easily set up a Jenkins server on AWS using Bitnami's AMI
Steps to set up a VNC server on CentOS 8.3
Set up a MineCraft Paper server on Ubuntu 20.04.1 LTS ② Update
Build a Minecraft server on AWS
[Ubuntu] Set up a Nukkit server
Set up Metabase service on Windows Server 2012
Set up an SSH server on WSL2 Ubuntu 20.04
Set up a CentOS virtual server with Vagrant
I tried using Log4j2 on a Java EE server
Creating a docker host on AWS using Docker Machine (personal memorandum)
Try launching a webAP server on the micro using Helidon
Set up ansible-playbook on Ubuntu 20.04
How to run a mock server on Swagger-ui using stoplight/prism (using AWS/EC2/Docker)
How to create a web server on an EC2 instance on AWS
Set up a Wordpress Docker environment without using the Worpdress image
Install Docker on Ubuntu and set up remote connection using tls
Using a local network on iOS 14
Minimal steps to set up a Ruby environment with rbenv on Ubuntu 20.04
[AWS SDK for Java] Set a retry policy on the S3 client