wget post-data purpose

234 views
Skip to first unread message

Benjamin Todd

unread,
Jun 4, 2015, 7:14:02 PM6/4/15
to jenkins...@googlegroups.com
Hi all,
I'm trying to get a post commit working correctly and I'd like to understand more about the purpose of the --post-data option in the post-commit example as showin below:

REPOS="$1"
REV
="$2"
UUID
=`svnlook uuid $REPOS`
/usr/bin/wget \
--header "Content-Type:text/plain;charset=UTF-8" \
--post-data "`svnlook changed --revision $REV $REPOS`" \
--output-document "-" \
--timeout=2 \ ${HOST}/subversion/${UUID}/notifyCommit?rev=$REV


If I replace it with random data (as shown below), Jenkins does not kick off a job. 

REPOS="$1"
REV
="$2"
UUID
=`svnlook uuid $REPOS`

POST_DATA
=`tr -cd '[:alpha:]' < /dev/urandom | fold -w10 | head -n1`

/usr/sfw/bin/wget \
--header="Content-Type:text/plain;charset=UTF-8" \
--post-data="${POST_DATA}" \
--output-document="-" \
--timeout=2 \
$
{HOST}/jenkins/subversion/${UUID}/notifyCommit?rev=${REV}

In both cases, the Jenkins log shows "
No subversion consumers for UUID e044f8b4-0b0e-11e5-a6c0-1697f925ec7b", but in the former (with the svnlook output) a build of the job is kicked off, while the latter (with random) data does not.  No other log messages are presented for the random string example. 

I believe using --post-data forces wget to POST as opposed to GET, but is the content it posts actually used?  If so, how since it appears to just be a change list?

Thanks,
Ben





Daniel Beck

unread,
Jun 5, 2015, 4:36:36 AM6/5/15
to jenkins...@googlegroups.com
On 05.06.2015, at 01:14, Benjamin Todd <benjamin...@gmail.com> wrote:

> I believe using --post-data forces wget to POST as opposed to GET, but is the content it posts actually used? If so, how since it appears to just be a change list?

Jenkins needs this to compare the URLs checked out by the projects in Jenkins with the list of changes in the commit to determine which projects need to poll for changes.

Benjamin Todd

unread,
Jun 5, 2015, 2:24:37 PM6/5/15
to jenkins...@googlegroups.com, m...@beckweb.net
When I run `svnlook changed --revision ${REV} ${REPO}`, it returns something similar to the following:

A   path/to/new/file/test_138
A   path
/to/new/file/test_139



So does Jenkins use this information from --post-data to determine which jobs to build? From above it would look for jobs with the subversion path of "path/to/new/file".  Is that functionality using a new line as a delimiter or can Jenkins use a different delimiter?

Thanks,
Ben

Daniel Beck

unread,
Jun 5, 2015, 6:38:32 PM6/5/15
to jenkins...@googlegroups.com
This is how it parses the text:
https://github.com/jenkinsci/subversion-plugin/blob/master/src/main/java/hudson/scm/SubversionRepositoryStatus.java#L102..L106

So, no, it cannot use a different delimiter. Do you check in files that have newlines as part of the filename, and they get broken into multiple lines?
> --
> 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/22b771d8-cb9d-4fb7-aaa3-60a882ad6665%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Benjamin Todd

unread,
Jun 8, 2015, 2:13:02 PM6/8/15
to jenkins...@googlegroups.com, m...@beckweb.net
I'm trying to keep from poking holes in the server proxy and kicking off of jobs via an ssh command to a locked down shell on the jenkins server from the subversion server (basically "ssh jenkins server 'wget --post-data <post-data> <wget-options> localhost:8080/jenkins/subversion/<UUID>/revsion=<REV>'").  The problem is that the new lines in the post-data are interpreted as either an indication of a new command by the shell or ssh shell or as another url by wget (depending on how I use quotes).  The new-lines do not survive the ssh call to the remote server.  I've tried multiple levels of quotes (and escaped quotes) and have not had success.

Reviewing the code, I understand the need for the post-data and in my experimentation I have been able to kick off two separate jobs with the same commit.  Not functionality I plan on using, but still good to know it is possible.

Ben

Daniel Beck

unread,
Jun 8, 2015, 2:25:26 PM6/8/15
to jenkins...@googlegroups.com
Try uploading a file with the svnlook output first, and use that as --post-file.

Benjamin Todd

unread,
Jun 15, 2015, 1:25:38 PM6/15/15
to jenkins...@googlegroups.com, m...@beckweb.net
That works.  Thanks for the suggestion.

Ben
Reply all
Reply to author
Forward
0 new messages