$ mkdir trader-stable.git $ cd trader-stable.git $ git init --bare Initialized empty Git repository in /Users/Shared/trader-stable.git/ $
Configuring automatic push by successfully build
TweetPosted on Sunday Mar 01, 2015 at 11:19PM in Jenkins
Making Jenkins to push to an another remote repository if build finishes successfully.
Recipe
-
Create a bare repository
-
Click
Add Repository -
Enter
Repository URL -
Click
Advanced… -
Enter
stabletoName -
Click
Add post-build action⇒Git Publisher -
Check
Push Only If Build Succeeds -
Click
Add Tag -
Enter
$BUILD_NUMBERtoTag to push -
Check
Create new tag -
Enter
stabletoTarget remote name -
Click
Save
Test
$ pwd /Users/kyle/tmp/trader $ echo 'push if succeeds test' >> hi.txt $ git commit -am 'push if succeeds test' $ git push origin master
Jenkins said Pushing tag 8 to repo stable
$ git remote add stable /Users/Shared/trader-stable.git $ git fetch stable remote: Counting objects: 1, done. remote: Total 1 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (1/1), done. From /Users/Shared/trader-stable * [new tag] 8 -> 8 $
Configuring automatic build by push for git repository
TweetPosted on Sunday Mar 01, 2015 at 07:15PM in Jenkins
We can start the build by send request to following URL.
http://YOURHOST/jenkins/job/PROJECTNAME/build
Recipe
In my case, Jenkins is deployed in /, and the server is running on port 18080. so the command to start a build of the job named trader will be:
curl http://localhost:18080/job/trader/build
So put following shell script into $ORIGIN_BARE_REPOSITORY/hooks/post-receive and execute chmod +x post-receive.
#!/bin/sh curl http://localhost:18080/job/trader/build
Testing
Push some modification as follows:
$ echo hook test >> hi.txt $ git add hi.txt $ git commit -m 'hook test' $ git push origin master
Check the build was run automatically as expected, and the output.
Creating a simplest Jenkins job against a git repository
TweetPosted on Sunday Mar 01, 2015 at 05:45PM in Jenkins
-
Click
New Item -
Enter
traderinItem nameand selectBuild a free-style software project -
Select
Gitand enterRepository URL -
Click
Add build step-Execute shell -
Enter
cat hi.txtintoCommand -
Click
Save -
Click
Build Now -
Click a Build History which just created by build
-
Click
Console Output
Creating a shared git repository on local filesystem
TweetPosted on Sunday Mar 01, 2015 at 05:04PM in Git
Tested with OS X 10.9.5.
Requirement
There are 2 users (kyle and jenkins). they want to have a shared git repository named trader on local filesystem. both of them can push changes into the repository.
Recipe
-
Create a group named
trader$ sudo dseditgroup -o create trader
-
Let join
kylenadjenkinsinto the grouptrader$ sudo dseditgroup -o edit -a kyle -t user trader $ sudo dseditgroup -o edit -a jenkins -t user trader
-
Create a bare repository
$ cd /Users/Shared $ mkdir trader.git $ cd trader.git $ git init --bare --shared
-
Change owning group of
trader.gittotrader$ cd ../ $ chown -R :trader trader.git
-
Make the repository writable by users in
tradergroup$ chmod -R g+w trader.git
Testing
-
Clone the repository
$ git clone /Users/Shared/trader.git
-
Make first commit by
kyle$ cd trader $ echo 'hi there' > hi.txt $ git add hi.txt $ git commit -m 'first commit from kyle'
-
Push to the parent repository
$ git push origin master
-
Switch to user
jenkins$ sudo su - jenkins
-
Clone the repository
$ git clone /Users/Shared/trader.git
-
Make first commit by
jenkins$ cd trader $ echo hi there from jenkins >> hi.txt $ git add hi.txt $ git commit -m 'first commit from jenkins'
-
Push to the parent repository
$ git push origin master
-
Pull the change made by
jenkinsfrom userkyle$ whoami kyle $ cat hi.txt hi there $ git pull origin master $ cat hi.txt hi there hi there from jenkins
Tags: git
JBeret JdbcItemWriter / JdbcItemReader example on EE environment
TweetPosted on Sunday Mar 01, 2015 at 12:11AM in JBatch
We need to use non transactional datasource for JdbcItemReader.
