Build-Deploy-Pipeline of a springboot app using Jenkinsfile

With Jenkins 2 the concept of pipelines became one of the core features of this great tool. In combination with job and pipeline dsl, it’s getting quite easy to code your build and deployment pipeline in Groovy instead of providing static config xmls or rigid job generators. Although some people might think, separation between build team and dev team has to be established due to responsibility concerns, actually the guys that write the application (no matter of dev, build, ops or others) should know best how to get the application through the pipeline. Weiter lesen

Simple deployment from Gradle to Artifactory

The maven ecosystem works perfectly together with JFrog’s Artifactory, a wide spreaded repository manager for GAV artifacts, debian artifacts, bower, npm, ….. . Gradle, the rising competitor of Maven and Ant, fits also to the maven ecosystem but tries to stay independent by providing no native support for Maven repistories but plugins with (in my oppinion!) low documentation. Let’s have a look at the differences between a full fledged Artifactory integrated Maven setup and a similar Gradle setup.
Weiter lesen

Groovy Testcase with SSH Mock

package eu.christophburmeister.playground

class SshApp {

    private static final long SSH_TIMEOUT = 10000

    public String execute(String user, String host, int port, boolean strictHostKeyChecking, String command){
        String cmd

        if (strictHostKeyChecking) {
            cmd = "ssh ${user}@${host} -p ${port} '${command}'"
        } else {
            cmd = "ssh ${user}@${host} -p ${port} -o StrictHostKeyChecking=no ${command}"

        def cmdWithNewShell = ['/bin/sh', '-c', cmd]

        println cmd

        Process process = cmdWithNewShell.execute()
        def outBuffer = new StringBuffer()
        def errBuffer = new StringBuffer()

        process.consumeProcessOutput( outBuffer, errBuffer )

        if( outBuffer.size() > 0 ) return outBuffer.toString()
        if( errBuffer.size() > 0 ) throw new Exception(errBuffer.toString())

import static com.aestasit.ssh.mocks.MockSshServer.*

/** ... Thx guys, nice work 🙂 */
class SshAppTest extends GroovyTestCase{
    private static final String EXPECTED_RESPONSE = '''
            total 20
            drwxr-xr-x 3 1100 1100 4096 Aug  7 16:52 .
            drwxr-xr-x 8 1100 1100 4096 Aug  1 17:53 ..
            drwxr-xr-x 3 1100 1100 4096 Aug  7 16:49 examples
    private static final String EXPECTED_SUBSTRING = 'Unknown command: cat /etc/hosts'
    private static final String USER = 'christoph'
    private static final String HOST = 'localhost'
    private static final int SSH_PORT = 2323
    private static final boolean HOST_KEY_CHECK = false
    private static final String COMMAND_POSITIVE = 'ls -la'
    private static final String COMMAND_NEGATIVE = 'cat /etc/hosts'
    private SshApp cut;

    protected void setUp() {
        cut = new SshApp()
        command('^ls.*$') { inp, out, err, callback, env ->
            out << EXPECTED_RESPONSE

    protected void tearDown() {

    /** the command 'ls' is available in the ssh server's expectation */
    void testExecutePositive(){
        String actualResponse_positive = cut.execute(USER, HOST, SSH_PORT, HOST_KEY_CHECK, COMMAND_POSITIVE)
        assertEquals(EXPECTED_RESPONSE, actualResponse_positive)

    /** the command 'cat' is not (!) available in the ssh server's expectation */
    void testExecuteNegative(){
        String excMsg = shouldFail(){
group 'eu.christophburmeister.playground'
version '1.0-SNAPSHOT'

apply plugin: 'groovy'

repositories {

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.3.11'
    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile group: 'com.aestasit.infrastructure.mock', name: 'groovy-sshd-mock', version: '0.3'