Jenkins - make кода с git


Материал из Wiki - Iphoster - 'the best ever support'

Перейти к: навигация, поиск

Jenkins - make кода с git

Пример сборки библиотеки git://github.com/afiskon/erlang-task-queue.git

# yum install git erlang rebar


Проверить чтобы был подключен плагин "Git Plugin" через Manage Jenkins» → «Manage Plugins


1) Создаем проект: New Item --> Вводим имя проекта --> Freestyle project
2) Source Code Management --> Git, URL repo: git://github.com/afiskon/erlang-task-queue.git
3) Branch Specifier (blank for 'any') : */master
4) Также можно поставить на автосборку приложения каждые 5 минут:

Build Triggers --> Poll SCM и указываем период каждые 5 минут:
*/5 * * * *


Заходим в проект и делаем Build Now, видим ошибки:

Started by user Anton
Building in workspace /var/lib/jenkins/jobs/task_queue/workspace
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git://github.com/afiskon/erlang-task-queue.git # timeout=10
Fetching upstream changes from git://github.com/afiskon/erlang-task-queue.git
> git --version # timeout=10
> git -c core.askpass=true fetch --tags --progress git://github.com/afiskon/erlang-task-queue.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 1d3a48d0620ed2108b0cf2fdbd2531778597970f (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 1d3a48d0620ed2108b0cf2fdbd2531778597970f
> git rev-list 1d3a48d0620ed2108b0cf2fdbd2531778597970f # timeout=10
[workspace] $ /bin/sh -xe /tmp/hudson301830978774391332.sh
+ make
rebar get-deps compile
==> workspace (get-deps)
==> workspace (compile)
dialyzer --src ./src
 Checking whether the PLT /var/lib/jenkins/.dialyzer_plt is up-to-date...
dialyzer: Could not find the PLT: /var/lib/jenkins/.dialyzer_plt
Use the options:
  --build_plt   to build a new PLT; or
  --add_to_plt  to add to an existing PLT
For example, use a command like the following:
  dialyzer --build_plt --apps erts kernel stdlib mnesia
Note that building a PLT such as the above may take 20 mins or so 
If you later need information about other applications, say crypto, you can extend the PLT by the command: dialyzer --add_to_plt --apps crypto For applications that are not in Erlang/OTP use an absolute file name.
make: *** [all] Error 1 Build step 'Execute shell' marked build as failure Finished: FAILURE


Выполняем то что просят из под пользователя jenkins, а именно:

# su jenkins -s /bin/bash -c 'git config --global user.name jenkins'
# su jenkins -s /bin/bash -c 'git config --global user.email jenkins@example.ru'
# su jenkins -s /bin/bash -c 'dialyzer --build_plt --apps erts kernel stdlib mnesia'
 Compiling some key modules to native code... done in 0m35.04s
 Creating PLT /var/lib/jenkins/.dialyzer_plt ...
Unknown functions:
 compile:file/2
 compile:forms/2
 compile:noenv_forms/2
 compile:output_generated/1
 crypto:block_decrypt/4
 crypto:start/0
Unknown types:
 compile:option/0
done in 1m5.18s
done (passed successfully)


Собираем снова проект через BUILD NOW - видим что ошибки нету. Логи можно подсматривать вот тут:

# tail -f /var/log/jenkins/jenkins.log
Jul 27, 2016 2:35:31 PM hudson.model.Run execute
INFO: task_queue #3 main build action completed: FAILURE
Jul 27, 2016 2:36:52 PM hudson.model.Run execute
INFO: task_queue #4 main build action completed: FAILURE
Jul 27, 2016 2:45:13 PM hudson.model.Run execute
INFO: task_queue #5 main build action completed: SUCCESS
Индекс цитирования