Basit bir ifadeyle Pipline, bir uygulamayı bulunduğu depodan alıp son kullanıcıya teslim etmeye yarayan, geliştirici tarafından hazırlanmış bir kurallar zinciridir. Kurallar zinciri herhangi bir şey olabilir mesela, kodu depodan almak (örnek: GitHub), uygulamayı hazırlamak (örnek: composer install), testleri çalıştırmak (örnek: PHPUnit), bir ortama iletmek (örnek: Staging) vs. Bunu gerçekleştirmek için, Jenkinsfile kullanarak pipeline ortamını otomatik bir şekilde yaratabiliriz. Aşağıdaki örnekte bir Jenkinsfile yaratacağız ve daha sonra bunu Jenkins'e yükleyip pipeline kurallarını çalıştıracağız.


Jenkinsfile


pipeline {
agent any

options {
timeout(time: 60, unit: 'SECONDS')
}

stages {
stage('Build') {
steps {
echo 'Building...'
}
}
stage('Test') {
steps {
echo 'Testing...'
}
}
stage('Deploy') {
steps {
echo 'Deploying...'
}
}
}
}

Pipeline


Jenkins'in ana sayfasında "New Item" linkine tıklayıp "Test" isminde yeni bir item yaratın ve sonraki sayfadan "Pipeline" seçeneğini seçin. "Pipeline" bölümündeki text alanına Jenkinsfile'ın içeriğini kopyaladıktan sonra kaydedip çıkın. Bu işlemden sonra "Build now" linkini tıklayıp pipeline testi yapabilirsiniz. Bu kadar!


Sonuç


Started by user root
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/Test
[Pipeline] {
[Pipeline] timeout
Timeout set to expire in 1 min 0 sec
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] echo
Building..
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] echo
Testing..
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy)
[Pipeline] echo
Deploying....
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timeout
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS