16/02/2019 - GIT, JENKINS, LINUX
Bu örneğimizde SSH kullanarak Jenkins'i GitHub'a entegre edeceğiz. Örnek olarak GitHub kütüphanesinde bulunan bir Jenkinsfile dosyasını kullanarak, Jenkins içinde bir Pipeline projesi yaratacağız.
Öncelikle, Jenkins sunucunuzun GitHub ile SSH üzerinden konuşabildiğinden emin olmanız gerekir. Connecting to GitHub with SSH sayfasındaki adımları takip edebilirsiniz.
Bu bizim örnek GitHub projemiz ve https://github.com/inanzzz/game
adresinden ulaşılabilir haldedir.
.
├── ci
│ └── pipeline
│ └── branch
│ ├── develop
│ │ └── Jenkinsfile
│ ├── feature
│ │ └── Jenkinsfile
│ └── master
│ └── Jenkinsfile
├── composer.json
├── composer.lock
├── src
│ └── Football.php
├── tests
│ └── FootballTest.php
└── vendor
Jenkins UI'ye giriş yaptıktan sonra aşağıdakileri uygulayın.
GitHub-inanzzz
).~/.ssh/id_rsa.pub
dosyasının içeriğini text alanına yapıştırın.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.
https://github.com/inanzzz/game
linkini kullanın.GitHub-inanzzz
seçeneğini seçin.*/master
'ı */develop
olarak değiştirin.ci/pipeline/branch/develop/Jenkinsfile
yazın."Build Now" linkine tıklarsanız, ilk build başarıyla çalıştırılmalı ve konsol çıktısı aşağıdakine benzemelidir.
Started by user admin
Obtained ci/pipeline/branch/develop/Jenkinsfile from git https://github.com/inanzzz/game
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/Game
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
using credential 7a41495c
Cloning the remote Git repository
Cloning repository https://github.com/inanzzz/game
> git init /var/lib/jenkins/workspace/Game # timeout=10
Fetching upstream changes from https://github.com/inanzzz/game
> git --version # timeout=10
using GIT_SSH to set credentials
> git fetch --tags --progress https://github.com/inanzzz/game +refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url https://github.com/inanzzz/game # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url https://github.com/inanzzz/game # timeout=10
Fetching upstream changes from https://github.com/inanzzz/game
using GIT_SSH to set credentials
> git fetch --tags --progress https://github.com/inanzzz/game +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/develop^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/develop^{commit} # timeout=10
Checking out Revision f63bf36b (refs/remotes/origin/develop)
> git config core.sparsecheckout # timeout=10
> git checkout -f f63bf36b
Commit message: "Very first commit"
First time build. Skipping changelog.
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] timeout
Timeout set to expire in 1 min 0 sec
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Code Pull)
[Pipeline] echo
Pulling...
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] echo
Building...
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] echo
Testing...
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Image Build)
[Pipeline] echo
Building...
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Image Push)
[Pipeline] echo
Pushing...
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy)
[Pipeline] echo
Deploying...
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timeout
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS