Skip to content

Instantly share code, notes, and snippets.

@serdroid
serdroid / cleanRepo.groovy
Created February 19, 2018 07:51
nexus-3 repository clean groovy script
import org.sonatype.nexus.repository.storage.Asset;
import org.sonatype.nexus.repository.storage.Component;
import org.sonatype.nexus.repository.storage.Query;
import org.sonatype.nexus.repository.storage.StorageFacet;
import org.sonatype.nexus.repository.storage.Query.Builder;
import groovy.json.JsonOutput;
import groovy.json.JsonSlurper;
def request = new JsonSlurper().parseText(args);
assert request.repoName: 'repoName parameter is required';
@serdroid
serdroid / gist:7bd7e171681aa17109e3f350abe97817
Created October 17, 2017 12:24
create commit and push to repo during CI build in gitlab
- generate ssh key for gitlab-runner user
- add ssh key to project's deploy keys (project/setting/repository)
add below commands into script section of .gitlab-ci.yml file.
# CI_REPOSITORY_URL contains gitlab-ci-token. replace start of the string up to '@' with git@' and append a ':' before first '/'
# example
# CI_REPOSITORY_URL=https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@example.com/gitlab-examples/ci-debug-trace.git
# should be git@example.com:/gitlab-examples/ci-debug-trace.git
- export PUSH_REPO=$(echo "$CI_REPOSITORY_URL" | sed -e "s|.*@\(.*\)|git@\1|" -e "s|/|:/|" )
# go to project directory in gitlab host machine
cd ~git/git-data/repositories/path/to/project/project.git
# make a directory named custom_hooks
mkdir custom_hooks
cd custom_hooks
cp /path/to/hook-file .
# put hook file into this directory
# and make it executable
chmod +x hook-file