Setting up an Online Jenkins Instance with Ngrok
Jenkins is a popular open-source automation server that allows you to automate various tasks, including building, testing, and deploying software. By default, Jenkins runs on port 8080, which is typically accessible within your local network. However, if you want to access your Jenkins instance from outside your network or share it with others, you can use Ngrok to create a secure tunnel to your local Jenkins server.
Ngrok is a handy tool that enables secure introspectable tunnels to localhost. It provides a public URL for your locally hosted application, allowing external access without exposing your local server to the internet.
In this article, we'll guide you through the process of setting up an online Jenkins instance using Ngrok. Let's get started!
Prerequisites
Before you begin, ensure that you have the following:
- Jenkins installed and running on your local machine.
- Ngrok downloaded and installed. You can download Ngrok from the official website at ngrok.com/download.
Step 1: Install Ngrok
To install Ngrok, follow these steps:
- Open your terminal and execute the following command:
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list && sudo apt update && sudo apt install ngrok
- This command adds the Ngrok repository to your system and installs Ngrok.
Step 2: Sign Up and Obtain Ngrok Auth Token
To use Ngrok, you need to sign up and obtain an authentication token. Follow these steps:
Visit the Ngrok website at ngrok.com and sign up for a free account.
After signing up, navigate to the "Setup & Installation" section on the Ngrok website.
Under "Connect your account", copy the provided command.
Return to your terminal and paste the command. This connects your Ngrok account to your local Ngrok installation.
Step 3: Create a Secure Tunnel to Jenkins
To create a secure tunnel to your Jenkins instance using Ngrok, follow these steps:
- In your terminal, run the following command:
ngrok http 8080
Ngrok will start and display a public URL that forwards requests to your local Jenkins server. This URL will look something like
https://randomstring.ngrok.io
.Keep the terminal window running to maintain the tunnel connection.
Step 4: Configure Webhook in Jenkins
To ensure that Jenkins can receive external notifications and trigger builds, you need to set up a webhook. Here's how to configure the webhook:
Access the Jenkins web interface by opening a browser and entering
http://localhost:8080
or the custom URL you specified during Jenkins setup.Log in to Jenkins using your credentials.
Navigate to the Jenkins project or repository for which you want to configure the webhook.
Go to the project settings or repository settings and look for the "Webhooks" section.
Add a new webhook and paste the Ngrok URL you obtained in Step 3 as the webhook URL.
Save the webhook settings.
Conclusion
Congratulations! You have successfully set up an online Jenkins instance using Ngrok. By creating a secure tunnel to your local Jenkins server, you can now access Jenkins from anywhere and share it with others.
Remember to keep the Ngrok tunnel running in your terminal to maintain the connection. If you need to access Jenkins in the future, start Ngrok and use the provided URL to access your online Jenkins instance.
Ngrok offers additional features and functionalities, such as custom domains and HTTPS support, which you can explore to further enhance your Jenkins setup.
Now you can enjoy the convenience of an online Jenkins instance, enabling you to automate your workflows and collaborate with others effectively. Happy building and deploying with Jenki
Top comments (1)
This is beautiful and insightful