Amazingly few people automate their Nexus administration. I guess the fault lies mostly in the company behind Nexus, who does very little to make their API usable and well documented.
This post https://blog.soebes.de/blog/2017/10/02/nexus-scripted-setup/ made me discover this API:
https://github.com/sonatype/nexus-public/blob/master/plugins/nexus-script-plugin/src/main/java/org/sonatype/nexus/script/plugin/RepositoryApi.java
Very good reading also here https://support.sonatype.com/hc/en-us/articles/115015812727-Nexus-3-Groovy-Script-development-environment-setup about using the Nexus book examples to automate the execution of these Groovy/Java scripts.
References http://www.javamonamour.org/2018/03/nexus-repository-administration.html on same topic of Automation (via REST api)
Sunday, September 30, 2018
Wednesday, September 26, 2018
git delete all tags matching a regex
this will delete all remote tags containig the "iap-copy" string (more complex cases can be achieved with egrep)
The method is very slow.... there are much faster ways, but this is very simple and reliable
tested with git 1.9.4
git clone myrepourl cd myproject git tag --list | grep iap-copy | sort > allnaughtytags.txt for mytag in `cat allnaughtytags.txt`; do git push --delete origin $mytag ; done
The method is very slow.... there are much faster ways, but this is very simple and reliable
tested with git 1.9.4
Labels:
git
Friday, September 21, 2018
Parsing command line arguments in Spring etc
lots of frameworks are reported here:
https://stackoverflow.com/questions/367706/how-do-i-parse-command-line-arguments-in-java/
but eventually I just want to do it using Spring classes
https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/env/SimpleCommandLinePropertySource.html
https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/env/JOptCommandLinePropertySource.html
The advantage in Spring is that you can directly bind the command line arguments to attributes, there is an example here
https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/env/CommandLinePropertySource.html
A very simple example:
and of course the JOptCommandLinePropertySource version is more robust...
Interesting also the https://projects.spring.io/spring-shell/ project, but only to write CLI applications
https://stackoverflow.com/questions/367706/how-do-i-parse-command-line-arguments-in-java/
but eventually I just want to do it using Spring classes
https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/env/SimpleCommandLinePropertySource.html
https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/env/JOptCommandLinePropertySource.html
The advantage in Spring is that you can directly bind the command line arguments to attributes, there is an example here
https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/env/CommandLinePropertySource.html
A very simple example:
package org.pierre.clidemo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.PropertySource;
import org.springframework.core.env.SimpleCommandLinePropertySource;
import org.springframework.boot.CommandLineRunner;
@SpringBootApplication
public class DemoApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
PropertySource ps = new SimpleCommandLinePropertySource(args);
// --file=pippo.txt --language=EN_TO_DE --firstOriginal=true
System.out.println("file=" + ps.getProperty("file"));
System.out.println("language=" + ps.getProperty("language"));
System.out.println("firstOriginal=" + ps.getProperty("firstOriginal"));
}
}
and of course the JOptCommandLinePropertySource version is more robust...
Interesting also the https://projects.spring.io/spring-shell/ project, but only to write CLI applications
Subscribe to:
Posts (Atom)