Reputation: 65
I'm quite new to Jenkins but as my project are starting to grow the need for a full CI increasing. So I'm looking to have a deploy task which will run if all passes. Now as Im using PHP for my server I don't want to publish via SSH the whole application each build. I would like to push only the files which have changed. Now in Jenkins I can get the revision but its showing me only the latest revision. I'm currently using batch file to get the variable value. What I need though is the list of changesets in the build as there could be more than one. Then use hg log -r %1:%2 --template "{file_mods}{file_adds}\n" to use from and too to get the list.
I am open to anyway to achieve this groovy/powershell or bat file. But any guidence on this would help as I'm getting somewhat lost looking through articles on the subject. I would have thought this would be a common thing so maybe Im missing something.
Thanks in Advance
Dean
Upvotes: 1
Views: 160
Reputation: 97285
I would like to push only the files which have changed
Obvious question|addition: "... changed since /this point in history/". You have to store somehow this data (latest changeset of deploy) and provide it to Jenkins job
use hg log -r %1:%2 --template "{file_mods}{file_adds}\n" to use
No. You can even at 1-st step use command, which'll prepare for you needed tree of files, and you have it: read hg help archive
You can tag every passed tests and deployed changeset in order to have this information later. You can really use any format of tag (because latest tag will be always detectable as "latest", regardless of the name used), I recommend to select pattern, which will produce unique ids (just less headache in process), but you can have something like hg tag -f DEPLOY
(-f for re-use existing name of tag, not the best style, but possible)
With tagging at last step for successful deploy (not build) for any tag-pattern you can always have set of changesets for deploy in the next time: it will be range from latest tag to tip. It will be
-r "last(tag()):tip"
After all, you have command, which build tree of files to deploy, like
hg archive "-Iset:status('last(tag())', 'tip', added() or modified())" -X .hgtags -rtip -tfiles "PATH/TO/ROOT/OF/TREE"
(notes: set
construction define all files from range of changesets, read hg help filesets
, last(tag()), tip
is our range from above p.2, added() or modified()
define which types have to be added to set: all changes, -X .hgtags
exclude from archive file hgtags, which was modified since last tag-revision, but not needed on site)
hg archive
can't handle this)ssh $SERVER
cd $SIE-ROOT$
hg up
Upvotes: 1