diff --git a/doc/index.rst b/doc/index.rst index 0c99cbb4d..78a0b527d 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -692,6 +692,12 @@ This will run the tests and commit the result to a Docker image `industrial-ci/r The hash is unique for each argument list, so `rerun_ci . ROS_DISTRO=melodic` and `rerun_ci . ROS_DISTRO=kinetic` do not mix up. However, it will keep consuming disk space with each new combination. +The cached images can be listed with +:: + + $ rosrun industrial_ci rerun_ci --list + + For maintainers of industrial_ci repository ================================================ diff --git a/industrial_ci/scripts/rerun_ci b/industrial_ci/scripts/rerun_ci index 6fb6adc8e..14a8be2e1 100755 --- a/industrial_ci/scripts/rerun_ci +++ b/industrial_ci/scripts/rerun_ci @@ -17,8 +17,33 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +function show_help { + cat - <<'EOF' +Usage: + rerun_ci --list|-l + rerun_ci [--clean|-c] TARGET_PATH [PARAM=VALUE>]...] + rerun_ci --rm TARGET_PATH [PARAM=VALUE>]...] +EOF +} + +case "$1" in +"-l" | "--list") + exec docker image inspect --format '{{index .RepoTags 0}} - {{.Comment}}' $(docker images -q industrial-ci/rerun_ci/*) + ;; +"--rm") + remove=true + ;; +"-c" | "--clean") + clean=true + ;; +"-h" | "--help" | "") + show_help + exit 0 + ;; +esac + if [ ! -d "$1" ]; then - echo "First argument need to be the target directory" + show_help exit 1 fi @@ -29,6 +54,13 @@ _COMMIT_IMAGE_MSG="$repo_dir $*" env_hash=($(sha256sum <<< "$_COMMIT_IMAGE_MSG")) _COMMIT_IMAGE="industrial-ci/rerun_ci/$(basename "$repo_dir"):${env_hash:0:12}" +if [ "$remove" ]; then + exec docker rmi $_COMMIT_IMAGE +elif [ "$clean" ]; then + docker rmi $_COMMIT_IMAGE +fi + + force_env=(_COMMIT_IMAGE=$_COMMIT_IMAGE _COMMIT_IMAGE_MSG=$_COMMIT_IMAGE_MSG) keep_env=(DOCKER_PORT=$DOCKER_PORT SSH_AUTH_SOCK=$SSH_AUTH_SOCK TERM=$TERM)