1

Gurus,

I am using windows jenkins and linux SVN to build java code using maven.

My requirements is to validate to proceed with build execution in jenkins job after verifying that is there no specific list of files are changed in latest triggered job.

if specific file is present we should get promot to continue job.

I know i can use command
svn diff -r REV:HEAD --summarize | findstr /g:"filesname.list"

how to get the last successful build SVN revision and latest checked out revision from jenkins in script at run time ?

Also how pre buld script in jenkins job provide me interface to give my goahead decison to continue job?

Slav
  • 27,057
  • 11
  • 80
  • 104
anthriksh2000
  • 233
  • 2
  • 4
  • 11

3 Answers3

1

I managed it somehow using -

$url= curl -s "http://localhost:8080/job/Rev-number/lastStableBuild/" | findstr "started by"; $url =~ /([0-9]+)/;

anyways have to install curl on windows.

anthriksh2000
  • 233
  • 2
  • 4
  • 11
0

Following might help:

echo $SVN_REVISION
svn_last_successful_build_revision=`curl $JOB_URL'lastSuccessfulBuild/api/json' | python -c 'import json,sys;obj=json.loads(sys.stdin.read());print obj["'"changeSet"'"]["'"revisions"'"][0]["'"revision"'"]'`
diff=`svn di -r$SVN_REVISION:$svn_last_successful_build_revision --summarize`

Please check this link for other suggestions too: How to get list of changed files since last build in Jenkins/Hudson

Community
  • 1
  • 1
Technext
  • 7,887
  • 9
  • 48
  • 76
0

First things first: there is no mechanism in Jenkins to "prompt" you for a decision. You can have all sorts of parameters for the build, and logic to decide whether to go ahead with [automated] build or not, but there is no way for a job to pause and wait for user input.

To get the last checked out revision by Jenkins, you can simply use the %SVN_REVISION_1% variable at Jenkins runtime. The _1 represents the first SVN module defined in your job configuration. If you have several modules defined, you can use %SVN_REVISION_2% and so on.

To actually get a revision of a "last successful build", you can use what Technext suggested in the other answer. Note that you would need command line curl available in your system, and obviously change his Linux syntax to Windows syntax.

Slav
  • 27,057
  • 11
  • 80
  • 104