How former Action Hooks works in Openshift 3

Solution Verified - Updated -

Environment

  • Openshift Enterprise
    • 3.x

Issue

  • If I want to build using STI and deploy from my code source and I want to launch a "post step" script declared in my sources (typically filling a database), how can I do this?
  • Do we have action hooks in Openshift Enterprise 3

Resolution

  • We do have Pod-based Lifecycle Hook which execute hook code in a new pod derived from the template in a deployment configuration. For more information please refer below article

  • We can also reuse the assemble script to achieve that:

  • create a ".s2i/bin/assemble" inside your source code

#!/bin/bash
echo "Before assembling"

/usr/libexec/s2i/assemble
rc=$?

if [ $rc -eq 0 ]; then
    echo "After successful assembling"
    touch /tmp/success 
else
    echo "After failed assembling"
    touch /tmp/fail
fi

exit $rc
  • Then you can create the application using a new-app command, like this:
oc new-app centos/ruby-22-centos7~https://$git_repo/ruby-ex

If you need to apply a new change in this assemble script you just need to start a new build, for instance:

oc start-build ruby-ex

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.