1

Does anyone know if it is possible to "notify" a Jenkins VI server whenever a new post is made on a headless wordpress installation?

The reason why I'm asking this is because I'm using gatsby to fetch data from a headless wordpress endpoint and I always need to trigger a new build manually whenever there is new content to be pushed. That's fine for me, but marketing and hr people don't know how to use jenkins (to be fair they shouldn't)

It would be great If I somehow could notify my CI that there is new content available, and thus a new build needs to be triggered automatically.

Pretty much like contentful and netlify work together. Whenever there is a new post, a webhook is sent to netlify and that triggers a new build. Only this time, all the services would be on an internal network, and the only thing public is the build folder from gatsby. So the content would be static.

Sorry if this is a dumb question. I'm not quite sure what to do here. Is this something that needs to be made on the wordpress side? Or on jenkins side?

Can someone please help me? Thank you!

0

Take a look at some of WordPress's Actions & Filters - in particular, you might want something like publish_post:

function my_custom_post_action( $post_id, $post ) {
    // Send out data to your service using something
    // like wp_remote_request:
    // https://codex.wordpress.org/Function_Reference/wp_remote_post
}

add_action( 'publish_post', 'my_custom_post_action', 10, 2 );

You may need to ensure that the post is actually "new", as this hook will be triggered any time a post's status is changed to "publish". The Action/Filter reference has a lot of other hooks you can use that are related to posts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.