Jenkins: How to Sync Local Repository with GitLab / Trigger from GitLab



If you want to update your code in the local repository from git (gitlab, github, gitorious), you need to run git pull into your repository. If you want to do this by Jenkins, you can create a job that can perform this action. There may be easier way to solve it but you can follow the instruction below:


Create a Job to Pull the repo
Jenkins > New Item > Freestyle Project > "OK"

Build > Build Steps > Execute Windows Batch Command> Enter your command and save it

Install GitLab Hook Plugin
Jenkins > Manage Jenkins > Manage Plugins > Find Correct Plugin > Install it


Create Deploy Keys on GitLab
GitLab > Your Project Page > Settings > Deploy Keys > Click 'New Deploy Key'



Be sure that you are changing your project settings!



Create Deploy Keys and Services on GitLab
GitLab > Your Project Page > Settings > Services > Click 'GitLab CI'


Enter token, run the following command and get the private_token

curl http://gitlab-url/api/v3/session --data 'login=jenkins@testrisk.com&password=pass'

set the url with your job in Jenkins: http://your_ci_url/jobs/your_job_you_want_to_trigger

Test It
Now if there is a new push to your project on GitLab, it will send a trigger to Jenkins to run the job specified, then it does its jobs and enjoy it :)


Comments

Popular posts from this blog

Selenium Error "Element is not currently interactable and may not be manipulated"

Change Default Timeout and Wait Time of Capybara

Performance Testing on CI: Locust is running on Jenkins

Selenium Chromedriver Error Message: u'unknown error: unable to discover open pages

Getting the text of elements in Espresso