Post commit hook failed with exit code 127: --post-data not found

33 views
Skip to first unread message

jack

unread,
May 16, 2018, 7:44:12 AM5/16/18
to Jenkins Users
Hi everyone,

I'm recently working on this automation solution for my dev team using SVN as version control, to run builds and tests automatically when a commit occurs. 

But each time when I commit my post-commit hook script fails me :/

post-commit hook failed (exit code 127) with output:
/url/to/our/svnServer/hooks/post-commit: 67: --post-data: not found  (which is odd : the --post-data line is not at line 67 which is the last line of the file)

I'm not able to find the exact same problem on the web so no solution found... My script looks like this (the same script from the official doc):



REPOS="$1"
REV="$2"

#path to svnlook
UUID=`svnlook uuid $REPOS`

#notifying jenkins for repository change
/usr/bin/wget \
  --header `wget -q --output-document - \
  --post-data "`svnlook changed --revision $REV $REPOS`" \
  --timeout=2 \
  http://my_jenkins_url:/subversion/${UUID}/notifyCommit?rev=$REV



Jenkins is on my machine, SVN server on another machine. So I'm using Putty to access to all the hooks on that machine.

In the global security section I have "Jenkins users database" checked, in autorisations I use matrix based security and I already gave anonymous users Read permission for jobs; As for my job config I already checked the SCM polling option and have a valid CRON (which works perfectly), also I checked "trigger builds remotely" and provided my own token (works fine too).

Do you think it might have something to do with the credentials that I set for Jenkins job to link with my repo on SVN? I haven't quite understood how this affects the commit: should I add something like --username and --userpassword into my post-commit hook accordingly to my credentials settings? Or is this because SVN is not on my machine and I'm using a SSH client to access hooks there yet I haven't set SSH server option in Jenkins? 

What might be the problem in your opinion? Does someone know how to use post-commit hook? Thank you so much if someone can provide some advice and insights :)


R. Tyler Croy

unread,
May 16, 2018, 10:17:46 AM5/16/18
to jenkins...@googlegroups.com
(replies inline)

On Tue, 15 May 2018, jack wrote:

> Hi everyone,
>
> I'm recently working on this automation solution for my dev team using SVN
> as version control, to run builds and tests automatically when a commit
> occurs.
>
> But each time when I commit my post-commit hook script fails me :/
>
> post-commit hook failed (exit code 127) with output:
> /url/to/our/svnServer/hooks/post-commit: 67: --post-data: not found (which
> is odd : the --post-data line is not at line 67 which is the last line of
> the file)
>
> I'm not able to find the exact same problem on the web so no solution
> found... My script looks like this (the same script from the official doc):
>
>
>
> REPOS="$1"
> REV="$2"
>
> #path to svnlook
> UUID=`svnlook uuid $REPOS`
>
> #notifying jenkins for repository change
> /usr/bin/wget \
> --header `wget -q --output-document - \
>
> 'http://my_jenkins_url/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'`
> --post-data "`svnlook changed --revision $REV $REPOS`" \
> --timeout=2 \
> http://my_jenkins_url:/subversion/${UUID}/notifyCommit?rev=$REV




While this isn't a Jenkins issue at all, I'll give ya a hand :)


There's a trailing \ character which is missing after the crumbIssuer line in
the script, causing the script interpreter to try to parse the next line as if
it were a new command (`--post-data`)



signature.asc

jack

unread,
May 24, 2018, 12:59:56 AM5/24/18
to Jenkins Users
Thank you Tyler Croy;

I copied this directly from jenkins official doc, so very curious why they forgot to put that final \ at the end of the line;

But still... I called a colleague and he added the \ at the end but we got immediately another error... which I don't remember anymore.

Finally I disabled the XSRF option in jenkins and used the script without crumb, and it fianlly worked lol

Baptiste Mathus

unread,
May 29, 2018, 11:10:19 AM5/29/18
to jenkins...@googlegroups.com


Le jeu. 24 mai 2018 à 06:59, jack <ricky.ro...@gmail.com> a écrit :
Thank you Tyler Croy;

I copied this directly from jenkins official doc, so very curious why they forgot to put that final \ at the end of the line;

Human mistake. Can you please tell us the link where you saw that so that we can fix it? Or even better fixing it yourself through a PR :). There's a link at the bottom of the page to reach the page corresponding page on the git repo.


But still... I called a colleague and he added the \ at the end but we got immediately another error... which I don't remember anymore.

Finally I disabled the XSRF option in jenkins and used the script without crumb, and it fianlly worked lol

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3cc9c9ec-f805-4b26-b10b-ac18ad816a55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages