Skip to content

R4ynaud/Creating-an-Azure-DevOps-Self-Hosted-Agent-on-Ubuntu-22.04

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 

Repository files navigation

Creating an Azure DevOps Self Hosted Agent on Ubuntu 22.04

image

Azure DevOps Self-Hosted Agent nedir, ne işe yarar ?

• Azure DevOps Self-Hosted Agent, Azure DevOps da kullanılan bir araçtır. Bu araç, Azure DevOps da yer alan CI/CD süreçlerinin yönetilmesinde kullanılır. Kendi bilgisayarınızda veya sunucunuzda çalışan bir agent olarak görev yapar ve Azure DevOps da yer alan görevleri yerine getirir. Bu sayede Azure DevOps üzerinde bulunan projelerin, kendi altyapınızda veya sunucunuzda da sorunsuz bir şekilde çalışmasını sağlar. Özellikle güvenlik gerektiren veya yüksek performans gerektiren projelerde kullanılmaktadır. Bu sayede tüm serverlarınızı daha efektif bir şekilde kullanabilirsiniz.

What is an Azure DevOps Self-Hosted Agent ?

• Azure DevOps Self-Hosted Agent is a tool used in Azure DevOps for managing CI/CD processes. It functions as an agent running on your own computer or server and performs tasks in Azure DevOps. This enables projects in Azure DevOps to run smoothly on your infrastructure or server. It is especially useful for projects requiring high security or high performance, allowing you to use all your servers more effectively.

1-) Kurulumdan önce işletim sistemimizin paketlerini güncellemek için aşağıdaki komutları çalıştırıyoruz.

1-) We run the following commands to update our operating system's packages before installation.

 sudo apt-get update  
 sudo apt-get upgrade

2-) Eğer işletim sistemimizde "WGET" yüklü değilse öncelikle wget kurulumu yapmamız gerekiyor, wget kurulumu yapmak için aşağıdaki komutu çalıştırın.

2-) If "WGET" is not installed on our operating system, we need to install it first. To install WGET, run the following command.

 sudo apt-get install wget

3-) Agent için yeni bir klasör oluşturuyoruz.

3-) We are creating a new folder for the agent.

 sudo mkdir azure-agent

4-) Organization Settings → Pipelines → Agent Pools a tıklayalım ve yeni bir pool oluşturmak için “Add Pool” a tıklayalım.

4-) Let's click on Organization Settings → Pipelines → Agent Pools and to create a new pool, click on "Add Pool".

image

image

image

image

5-) Açılan ekranda pool için isim ve açıklama yazmanız gerekmektedir. Tüm pipelinelara erişim yetkisi vermek için “Grant access permission to all pipelines” ı seçebilirsiniz.

5-) On the screen that appears, you need to enter a name and description for the pool. You can select "Grant access permission to all pipelines" to give access permission to all pipelines.

image

image

• Yukarıdaki adımları tamamladıktan sonra bizi aşağıdaki ekran karşılamaktadır.

• After completing the above steps, we are greeted with the following screen.

image

6-) “New agent” a tıklayalım. İşletim sistemine göre agentı indirmeniz gerekmektedir.

6-) Click on "New Agent". You will need to download the agent according to your operating system.

image

7-) Agent'ı indirmek için aşağıdaki komutu çalıştırıyoruz.

7-) We use the following command to download the agent.

 wget https://vstsagentpackage.azureedge.net/agent/2.218.1/vsts-agent-linux-x64-2.218.1.tar.gz

image

8-) ".tar" uzantılı arşiv dosyasını bulunduğumuz klasöre çıkartmak için aşağıdaki komutu çalıştırıyoruz.

8-) We run the following command to extract the ".tar" archive file to the current directory.

 tar -xvf vsts-agent-linux-x64-2.218.1.tar.gz

image

9-) Personal Access Token’ı oluşturalım, bunun için aşağıdaki adımları sırasıyla uygulamamız gerekiyor.

9-) Let's create a 'Personal Access Token' by following the steps below in order.

• User settings → Personal Access Token → New Token

• Burada hangi organization için bu agenta yetki vermek istiyorsanız onu seçmelisiniz. Sonrasında expiration için 30–60–90 günlük yerine “Custom defined” seçeneği ile daha uzun bir süre verebilirsiniz, 1 seneyi aşmamak koşuluyla.

• Here, you should select the organization for which you want to authorize this agent. Afterwards, you can provide a longer expiration period by selecting the "Custom defined" option instead of 30-60-90 days, provided that it does not exceed 1 year.

image

image

image

image

10-) Personal Access Token’ı oluşturduktan sonra aşağıdaki gibi bir mail almamız gerekiyor.

10-) After creating the Personal Access Token, we need to receive an email like the following.

image

11-) " config.sh " çalıştırıp agentı create etmeye başlıyoruz, bunun için aşağıdaki bazı komutları sırasıyla çalıştırmamız lazım.

11-) We need to run some commands in order to create the agent by running "config.sh". Here are the commands that we need to run in order.

 export AGENT_ALLOW_RUNASROOT="1"
 ./config.sh
 Y
 https://dev.azure.com/Organization Name
 PAT
 Agent Pool Name (Dogukan)

12-) Agent'ı sorunsuz oluşturduktan sonra aşağıdaki gibi bir çıktı almamız gerekiyor.

12-) Once the Agent is created successfully, we should receive an output like the following.

image

image

13-) " Offline " olan agentı çalıştırmak için " run.sh " çalıştırmamız gerekiyor.

13-) To run the agent that is "Offline", we need to execute "run.sh".

 ./run.sh

image

image

14-) Agentı sorunsuz oluşturduktan örnek bir projede çalıştığını test edelim.

14-) Let's test if the agent works properly in a sample project after creating it.

image

image

image

image

15-) Agent sorunsuz çalıştıktan sonra aşağıdaki gibi bir mail gelmesi gerekiyor.

15-) After the successful execution of the agent, you should receive an email similar to the following.

image

16-) Agent schedule.

• Profesyonel iş hayatında büyük projelerde çalışmaya başladığımız zaman bütün agentlar'ı manuel yönetmek biraz karmaşık ve zor olabilir, böyle durumlarda imdadımıza Azure DevOps'un " Agent Schedule " özelliği yetişiyor. Bu özellik, oluşturulan agent'ı tercihlerimize göre yönetmemizi sağlar. Yani agent'ı önceden planlayarak istediğimiz gün ve saat aralığında çalıştırabiliyoruz.

• When starting to work on large projects in a professional business environment, manually managing all agents can be a bit complicated and difficult. In such situations, Azure DevOps' "Agent Schedule" feature comes to our aid. This feature allows us to manage the created agent according to our preferences. That is, we can run the agent on the day and time range we want by planning it in advance.

• Örnek bir projede bu özelleği denemek için aşağıdaki adımları tek tek uygulamamız gerekiyor.

• To try this feature on a sample project, we need to follow the steps below one by one.

 Pipelines → Edit Pipelines → Triggers → Scheduled → Add 

image

image

image

image

image

image

image

• Sorunsuz çalışıp çalışmadığını kontrol ederken dikkat etmemiz gereken alan 'Scheduled' yazan 'Summary' bölümüdür.

• When checking for smooth operation, the area we should pay attention to is the "Summary" section indicating "Scheduled".

image

image

About

Creating-an-Azure-DevOps-Self-Hosted-Agent-on-Ubuntu-22.04

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published