Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a real git repo during an Openshift build?

Tags:

git

openshift

When Openshift builds from a git repository, the source is cloned/exported in such a way that the clone is not a git repo, i.e. there's no .git directory. Anyone know how to change this behaviour to a real clone?

There's nothing in the relevant documentation (https://docs.openshift.com/container-platform/3.5/dev_guide/builds/build_inputs.html#source-code) but the docs aren't always what they could be.

Our use case is that our project uses a gradle plugin that adds information about the git state to the build artefact. This won't build in Openshift.

like image 897
Adrian Avatar asked Nov 03 '25 22:11

Adrian


1 Answers

When writing a S2I builder, by default source code will be injected into the directory /tmp/src. Your custom assemble script, if it needs to keep files from what is being injected, would move or copy files to their final location, such as /opt/app-root/src. Usually this is done before any compilation phase if it occurs. The build would then run in the target directory.

When moving or copying files and using a glob wildcard, you need to make sure hidden files starting with '.' are included. For example:

shopt -s dotglob
echo "---> Installing application source ..."
mv /tmp/src/* ./

If you don't have shopt -s dotglob, then a directory such as .git would not be included. This would be a problem if the subsequent build expected the .git directory to exist.

If you were using someone else's S2I builder and the .git directory was being left behind, you could include an executable .s2i/bin/assemble script in your application code directory and add to it.

#!/bin/bash

mv /tmp/src/.git ./

/usr/libexec/s2i/assemble

This assumes original assemble script was in typical location of /usr/libexec/s2i/.

like image 53
Graham Dumpleton Avatar answered Nov 06 '25 22:11

Graham Dumpleton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!