Unable to get content from $post on first publish

The third parameter for transition_post_status is the post object. Use it.

add_action( 'transition_post_status', 'dostuff', 10, 3 );

function dostuff( $new_status, $old_status, $post ) {
}

When in doubt, do not use globals. They are not reliable, they make your code hard to test and to read.