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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Ricky LI
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



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 :)


--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/212cd583-b9b1-4b8e-84fd-7cef6366d80f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

R. Tyler Croy
(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`)



--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/20180516141729.GE3395%40grape.lasagna.io.
For more options, visit https://groups.google.com/d/optout.

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Ricky LI
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

--
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 [hidden email].
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 | Threaded
Open this post in threaded view
|

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

Baptiste MATHUS


Le jeu. 24 mai 2018 à 06:59, jack <[hidden email]> 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 [hidden email].
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.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CANWgJS5H_BMA86E1LHux0C7mLdbV9gArG_gRU-3eh4rf3Wo_rA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.