top of page
Search

Jenkins, AWS, && Xcode



We talked about getting into DevOps as a career change in our previous article. But let's talk about some of the tools we use to automate development operations, starting with Jenkins. Jenkins is as an open-source automation server primarily used for continuous integration and continuous delivery (CI/CD). Jenkins is one of the more commonly used tools by developers who need to automate builds, tests, and deployments. There are certainly tiers (and tears) to understanding Jenkins. Let’s start with where many host Jenkins: AWS.


Hosting Jenkins on AWS

When it comes to hosting your Jenkins server, Amazon Web Services (AWS) offers various options to cater to the unique needs of any old company. Each option comes complete with its own advantages and considerations:


  • Amazon EC2: Provides virtual machines that replicate on-premises servers, offering full control and customization. However, managing infrastructure manually can be time-consuming.

  • AWS CodeBuild: A managed build service designed for continuous integration, offering pre-configured build environments and simplified setup. However, it might not be suitable for complex pipelines.

  • AWS CodeDeploy: A managed deployment service that integrates seamlessly with Jenkins for automated deployments. However, it requires additional configuration and might not be cost-effective for small-scale deployments.

  • AWS Elastic Beanstalk: A managed platform for web applications, integrating Jenkins for deployment automation.This option offers ease of use but might lack flexibility for specific needs.


Managing EC2 instances requires more technical knowledge than many of the other options, while managed services offer simplified setups. Complex pipelines might benefit from the customization of EC2, while simpler use cases can leverage managed services and save lots of time and money. Smaller teams might find managed services cost-effective, but larger teams with dedicated DevOps resources almost always want EC2's flexibility.


Getting an EC2 instance running is fairly straight-forward. Armed with that, consider the following steps to finish an Jenkins install (although we’ll come back to some of the step-by-step stuff in a bit):


1. Launch an EC2 Instance:

  • Choose an appropriate Amazon Machine Image (AMI) like Amazon Linux 2.

  • Select the desired instance type based on an expected build load (make it small at first and scale up).

  • Configure security groups to allow access to the Jenkins web interface (port 8080).

2. Install and Configure Jenkins:

  • Follow the standard installation instructions for Jenkins on your chosen Linux distribution.

  • Install recommended plugins for AWS integration.

  • Configure AWS credentials for accessing resources like S3 buckets for storing build artifacts.

3. Secure Your Instance:

  • Set a strong password for the initial admin user.

  • Install security plugins like "Matrix Authorization Strategy" for user access control.

  • Consider hardening security groups and enabling two-factor authentication.

4. Optimize and Integrate:

  • Use plugins like "AWS EC2 Slave Plugin" to scale build agents automatically based on workload.

  • Integrate with other AWS services like CodePipeline for continuous delivery workflows.

  • Monitor resource usage and adjust your instance type or utilize Auto Scaling for cost optimization.


Also, look into Terraform to automate infrastructure provisioning and management for greater efficiency, once Jenkins is deployed (otherwise the work to get it configured will be doubled or tripled as settings change). Further, AWS CloudFormation allows admins to use Infrastructure as Code (IaC) techniques for repeatable and scalable deployments. Finally, check out Jenkins X ( https://jenkins-x.io/v3/ ) to leverage a cloud-native approach for simplified CI/CD on Kubernetes.


Install Jenkins

Now let’s get into the specifics of installing Jenkins, both on a terrestrial server and on a cloud instance. Before starting on an installation journey, make sure to have:


  • A server: This can be a physical machine, a virtual machine in the cloud, or even a containerized environment. Popular choices include Ubuntu, Fedora, or CentOS.

  • Root access: This is essential for installing and configuring software on your server.

  • Basic understanding of command-line interfaces: Familiarity with navigating and executing commands in a terminal window will be helpful.


There are two main ways to install Jenkins:


  • Package Manager: If you're using a popular Linux distribution like Ubuntu, Debian, or CentOS, leveraging the built-in package manager is often the simplest approach.

  • War File: This option offers more flexibility and is suitable for custom environments or manual installations.


For environments where there’s a package manager available, use the following incantations:


1. Update the system:

sudo apt update (for Ubuntu/Debian)
sudo yum update (for CentOS/RHEL)

2. Install Jenkins:

sudo apt install jenkins (for Ubuntu/Debian)
sudo yum install java-11-openjdk-devel jenkins (for CentOS/RHEL)

3. Start and enable Jenkins:

sudo systemctl start jenkins (for Ubuntu/Debian)
sudo systemctl enable jenkins (for Ubuntu/Debian)
sudo systemctl start jenkins.service (for CentOS/RHEL)
sudo systemctl enable jenkins.service (for CentOS/RHEL)

If a package manager can’t be used (or if an alternate method is desired, consider a war file installation:


1. Download the War file:

Visit the official Jenkins website (https://jenkins.io/download/) and choose the appropriate War file for your Java version.

2. Install Java:

Ensure you have Java installed on your system. The recommended version is Java 11 or later.

3. Deploy the War file:

Place the War file in a suitable location like /opt/jenkins. Run the following command to start the server:

java -jar jenkins.war

4. Access the Jenkins web interface:

Open a web browser and navigate to http://localhost:8080.


Securing the Jenkins Instance:

After installation, remember to secure your Jenkins instance by:


  • Setting a strong initial password during the initial setup.

  • Installing security plugins.

  • Configuring user authentication and authorization.


Also think about how to use it to get even more productive, which often involves thinking much deeper or looking into the following:


  • Plugins: Extend Jenkins functionality with numerous plugins for build tools, testing frameworks, deployment platforms, and more.

  • Pipelines: Create complex CI/CD workflows using declarative pipelines for greater flexibility and control.


Jenkins and Xcode

Now that there’s a Jenkins enivronment, let’s actually let it help with some Xcode stuffs. For iOS developers seeking to automate their build and testing processes, the duo of Jenkins and Xcode kinda’ kicks butt. Jenkins combines seamlessly with Xcode (although honestly Xcode Cloud is a bit more seamless but a bit less overall useful (for now)) to help automate code builds, testing, and deployments.


Step 1: Install the Xcode Plugin in Jenkins:

  1. Access your Jenkins dashboard and navigate to Manage Jenkins > Manage Plugins.

  2. In the Available tab, search for Xcode and install the Xcode Integration plugin.

  3. Restart Jenkins for the plugin to take effect (don’t forget this step, I do a lot).


Step 2: Create a Freestyle Project in Jenkins:

  1. Click New Item in the Jenkins dashboard.

  2. Select Freestyle Project and name it appropriately.

  3. Under General, choose your Xcode project repository using the appropriate plugin (e.g., GitHub Plugin).

  4. In the Source Control Management section, configure branch selection and other options as needed.


Step 3: Configure the Xcode Build Step:

  1. Under Build Steps, click Add build step and select Xcode build.

  2. Provide the following information:

  • Workspace Directory: Path to your project's workspace directory.

  • Project Name: Name of your Xcode project.

  • Scheme: Choose the build scheme you want to use (e.g., Debug, Release).

  • Target: Select the specific target within your scheme (e.g., your app).

  • Configuration: Choose the build configuration (e.g., Debug, Release).

  • (Optional) You can further customize options like signing and provisioning by enabling relevant checkboxes.


Step 4: (Optional) Add Post-Build Actions:

  1. Under Post-build Actions, you can add various steps like:

  • Archiving: Automatically archives your built app.

  • Running tests: Execute unit and UI tests using XCTest.

  • Deploying: Set up automated deployment to devices or app stores (requires additional configuration).


Step 5: Save and Run the Job:

  1. Click Save to finalize your project configuration.

  2. Trigger the build manually or set up automatic triggers based on code changes or other events.


A few other things to look at include other plugins to do things like scan code quality analysis, testing coverage, etc. Anything that has to be touched manually might just have a plugin. After all, developers think about automating more than the average bear. Also consider environment variables for dynamic configuration adjustments in your build steps. Then there’s the biggee: deploying scripts for any old task. That’s the big time saver, although honestly scripting is something that most can learn as they go, or probably just find on the old GitHubs.


Remember that that Jenkins is infinitely flexibility. Things like declarative syntax and integration with other tools allows it to cater to specific needs and build a robust, automated DevOps workflow. Xcode isn’t infinitely flexible, but Jenkins helps to close the automation gap so developers can focus on, you know, writing code.

20 views0 comments

Recent Posts

See All

Comments


bottom of page