Показаны сообщения с ярлыком CI. Показать все сообщения
Показаны сообщения с ярлыком CI. Показать все сообщения

четверг, 20 февраля 2014 г.

[ANTHILL] Get Project's workflows method

There is 4 methods:
<Project>.getWorkflowArray() -- returns all active workflows
<Project>.getCompleteWorkflowArray() -- returns all workflows, including inactive
<Project>.getOriginatingWorkflowArray() -- returns all active originating workflows
<Project>.getNonOriginatingWorkflowArray() -- returns all active non-originating workflows

Just a note :)

среда, 2 октября 2013 г.

AntHillPro: Create, manage and delete environments via BeanShell scripts

Creating new entity (project, environment etc)

Lets assume that we need to create new environment within script
First of all, all new stuff will be applied into database only after step ends. When you create new environment you can't manipulate it, you can only add Properties on it, but you can't add agents or you cant add it into Environment Group, you will get an Exception because environment still not exists in scope of anthill. Same exception will happen if you will try to manipulate newly created project or some other instance. So, remember, if you create something you need to do:
  1. <your_new_entity> = new <Something>;
  2. <you_new_entity>.store();
  3. Finish step.
On next step your new entity will be in database and available for manipulation in anthill, you can add it into server groups, projects etc.

Adding into Environment Group

It is quite simple:
  1. Get environment group: EnvironmentGroup envGroup = EnvironmentGroupFactory.getInstance().restore( envGroupID );
  2. envGroup.addServerGroup( env ) , where env should be instance of ServerGroup
I want to point that you do not need to call .store() method, it will store by itself after the end of the step.

Adding into project's workflows.

There is a one limitation: you can add environment only in non originating workflows.
It also simple:
  1. Get project: Project prj = ProjectFactory.getInstance().restore( projectID );
  2. Get non-originating workflow like Workflow wf = prj.getWorkflow( nonOrigWFID ) or get an array of workflows Workflow[] wfArray = prj.getNonOriginatingWorkflowArray() and iterate over it.
  3. Add environment into it: wf.addServerGroup( env ) , where env should be instance of ServerGroup
Also you do not need to call .store() method here.

Deleting environment

In first part we have created environment and added it into environment group and workflows. Now if you want to delete it from anthill you need to delete it from all workflows where this environment is used.
It's not quite obvious, but... :) Here will be 3 steps in total: 

First step:

  • Get environment: ServerGroup env = ServerGroupFactory.getInstance().restoreForName( "my-env-name" );
  • Get environment's group: EnvironmentGroup[] envGroupArray = EnvironmentGroupFactory.getInstance().restoreAllForEnvironment( env );
Get all non-originating workflows that use this environment. In docs I've found method in WorkflowFactory:
  • Workflow[] wfInEnvArray = WorkflowFactory.getInstance().restoreAllNonOriginatingWorkflowsForEnvGroupsInEnvironment( env, envGroupArray, "*", "*", "*" );
we got all required variables earlier. Then you just need to iterate over this list and use <workflow>.removeServerGroup( env ); 
On this point Job step should finish and all removals will be applied into database, without it we can't delete environment, you'll get en exception that this env is in use.

Second step:

Also before delete you need to remove this environment from the environment group.
We have environment group which this environment belongs to, so just remove: envGroup.removeServerGroup( env ); 

Third step:

Just get ServerGroup object for required environment and call .delete() method.

четверг, 18 октября 2012 г.

Конфигурим Jenkins: добавляем Slave в Master

Предположим, что у нас есть 2 машины, на одной из них (Master) установлен и запущен Jenkins. Задача добавить вторую машину в Master.

Ставим Jenkins на CentOS 6

Нашел 2 варианта через tomcat5 и через yum.

Вариант установки через YUM

Качаем репу с сайта Jenkins'a
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo

Либо пишем репу вручную:
# vi  /etc/yum.repos.d/jenkins.repo
Then paste the following and save (ESC+w+q)
[jenkins]
name=Jenkins
baseurl=http://pkg.jenkins-ci.org/redhat/
gpgcheck=1
Далее добавляем GPG ключ:
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key

Обновляем YUM и ставим:
yum install jenkins

Если все ок, то jenkins будет доступен по адресу http://yourhost:8080/jenkins

Вариант установки через Tomcat 5

 Ставим Java, Ant и Tomcat5
yum install -y java ant
yum install tomcat5 tomcat5-webapps tomcat5-admin-webapps

Then we need to add Tomcat to our server startup
chkconfig --add tomcat5
Now edit Tomcat configuration file to add Hudson home directory (We will use /data/hudson/)
vi /etc/tomcat5/tomcat5.conf
Add at the bottom of the file
# If you wish to further customize your tomcat environment,
# put your own definitions here
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
# Just do not forget to export them :)
HUDSON_HOME=/data/hudson/
CATALINA_OPTS="-DHUDSON_HOME=/data/hudson/ -Xmx512m"

Ставим Hudson (Jenkins) 2.0.0

Идем в директорию WebApps
cd /var/lib/tomcat5/webapps/
Качаем последнюю версию Hudson с сайта http://hudson-ci.org/ или Jenkins с сайта http://jenkins-ci.org/
wget http://java.net/projects/hudson/downloads/download/war/hudson-2.0.0.war
mv hudson-2.0.0.war hudson.war
Теперь создадим рабочую директорию для Hudson и дадим права на нее Tomcat'у
mkdir /data/hudson
chown tomcat.tomcat /data/hudson/
Ну и перезапустим Tomcat
 /etc/init.d/tomcat5 restart
Если все хорошо, то у Вас успешно откроется Hudson/Jenkins по адресу http://yourhost:8080/hudson/

Важное дополнение при установке на CentOS

При установке java поставится версия GCJ, которая НЕ работает с Jenkins'ом!

Чтобы в этом убедиться, вы можете выполнить команду
java -version
java version "1.5.0"
gij (GNU libgcj) version 4.4.6 20110731 (Red Hat 4.4.6-3)

Эта версия не совместима в Jenkins, необходимо поставить OpenJDK версию Java. Делается это следующим образом.
yum remove java
yum install java-1.6.0-openjdk

Теперь у Вас установлена правильная версия:
java -version
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.6) (rhel-1.43.1.10.6.el6_2-i386)
OpenJDK Client VM (build 20.0-b11, mixed mode)
OpenJDK Client VM (build 20.0-b11, mixed mode)

среда, 17 октября 2012 г.

Ставим Jenkins на Gentoo

Introduction

For now this Gentoo Repository is just a copy of my local overlay/repository.

Disclaimer

You can use it on your own risk without any warranty.

Paludis

I use Paludis instead of Portage, so here is instructions for Paludis. You can read more about Paludis from official site.

Add repository

Create file /etc/paludis/repositories/godin.conf :
importance = 20
location = ${ROOT}/var/paludis/repositories/godin
sync = svn+http://godin-gentoo-repository.googlecode.com/svn/trunk/repository/
format = ebuild
names_cache = ${location}/.cache/names
write_cache = ${location}/.cache/metadata
Sync : mkdir -p /var/paludis/repositories/godin/.cache/{metadata,names}
paludis --sync x-godin

Optionally you can unmask everything from this repository by adding following line to /etc/paludis/keywords.conf :
*/*::godin ~x86

Useful stuff

Layman

Since I don't use Layman, it wasn't tested.
layman -f -o http://godin-gentoo-repository.googlecode.com/svn/trunk/layman.xml -a godin
or edit your /etc/layman/layman.cfg and add new overlay list :
overlays  : http://www.gentoo.org/proj/en/overlays/layman-global.txt
            http://godin-gentoo-repository.googlecode.com/svn/trunk/layman.xml
Add to sync list :
layman -S
layman -L
layman -a godin