Code Monkey home page Code Monkey logo

Comments (11)

tomasbjerre avatar tomasbjerre commented on June 1, 2024

Can you supply complete pipeline, request with curl command and response?

from generic-webhook-trigger-plugin.

yuchengren avatar yuchengren commented on June 1, 2024

Can you supply complete pipeline, request with curl command and response?
`
pipeline {
agent any

environment {
SCRIPT_PROJECT_ROOT = "/Users/macuser/PycharmProjects/smartscripts"
}

triggers {
GenericTrigger(
genericVariables: [
[key: 'BODY',
value: '$',
expressionType: 'JSONPath', //Optional, defaults to JSONPath
regexpFilter: '', //Optional, defaults to empty string
defaultValue: '' //Optional, defaults to empty string
],
],
causeString: 'Generic Cause',
token: 'gitlab',
printContributedVariables: true,
printPostContent: true,
silentResponse: true,
)
}

stages {
stage('action') {
steps {
sh "export PYTHONPATH=${SCRIPT_PROJECT_ROOT} && python3 -u ${SCRIPT_PROJECT_ROOT}/android/jenkins/webhook/webhook-gitlab.py
--data $BODY
"
}
}
}
}
`

the jenkins execute log:
`

  • python3 -u /Users/macuser/PycharmProjects/smartscripts/android/jenkins/webhook/webhook-gitlab.py --data object_kind:push event_name:push ...
    `

$BODY output is not raw json,but a JSONPATH string.

from generic-webhook-trigger-plugin.

tomasbjerre avatar tomasbjerre commented on June 1, 2024

I am missing the curl-command.
Also the log, ans specifically the contributed variables.

from generic-webhook-trigger-plugin.

yuchengren avatar yuchengren commented on June 1, 2024

I am missing the curl-command. Also the log, ans specifically the contributed variables.

It it just trigger by gitlab webhook, the URL is
http://JENKINS_URL/generic-webhook-trigger/invoke?token=gitlab,
I want to do something after push, and I need to raw json body

from generic-webhook-trigger-plugin.

tomasbjerre avatar tomasbjerre commented on June 1, 2024

This is impossible to investigate if you do not supply something that I can reproduce.

from generic-webhook-trigger-plugin.

yuchengren avatar yuchengren commented on June 1, 2024

the gitlab we

This is impossible to investigate if you do not supply something that I can reproduce.

sorry, I do not understand, Has any else Do you need?
The webhook is not a curl-command, it is just trigger by gitlab push event。the gitlab push event, webhook body sample is on docs: https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html

from generic-webhook-trigger-plugin.

yuchengren avatar yuchengren commented on June 1, 2024

more jenkins log:
Generic Cause
GenericWebhookEnvironmentContributor
Received:

{"object_kind":"push","event_name":"push",...}

Contributing variables:

BODY = {"object_kind":"push","event_name":"push",..}
  • python3 -u /Users/macuser/PycharmProjects/smartscripts/android/jenkins/webhook/webhook-gitlab.py --data object_kind:push event_name:push...

===
the BODY variables in log is Json,but in pipeline shell command $BODY is not json, but JSONPATH format

from generic-webhook-trigger-plugin.

tomasbjerre avatar tomasbjerre commented on June 1, 2024

So you are saying that if you do:

sh """
 echo "BODY: " + BODY
"""

You do not get BODY: {"object_kind":"push","event_name":"push",..} ?
What exactly do you get?

from generic-webhook-trigger-plugin.

yuchengren avatar yuchengren commented on June 1, 2024
  • object_kind:push event_name:push ...

Yes ! ,
sh "export PYTHONPATH=${SCRIPT_PROJECT_ROOT} && python3 -u ${SCRIPT_PROJECT_ROOT}/android/jenkins/webhook/webhook-gitlab.py
--data $BODY "
the $BODY is not json, but JSONTPATH format string -> object_kind:push event_name:push ...

from generic-webhook-trigger-plugin.

tomasbjerre avatar tomasbjerre commented on June 1, 2024

If you print the variable, like I said, you will see that it is the raw json.

You problem is probably is how you are using the value. See https://stackoverflow.com/a/38385227/2477084

from generic-webhook-trigger-plugin.

yuchengren avatar yuchengren commented on June 1, 2024

If you print the variable, like I said, you will see that it is the raw json.

You problem is probably is how you are using the value. See https://stackoverflow.com/a/38385227/2477084

you are right! the BODY is a raw json. thanks very much . The problem is that, shell command json param is need to wrap by ''

from generic-webhook-trigger-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.