Bash command inside Groovy

Bash command inside Groovy, helps with improving your Jenkins pipelines.

8

Votes

def run_bash_command(){
    try {
        cmd_output = sh script:  """
        #!/bin/bash -e
        [YOUR_BASH_COMMANDS_HERE]
        """, returnStdout: true
        return cmd_output
    }
    catch (error) {
        echo "${error}"
        currentBuild.result = 'FAILURE'
        throw error
    } 
}

Vote Here

You must earn at least 1 vote on your snippets to be allowed to vote

Terms Of Use

Privacy Policy

Featured snippets are MIT license

Gears & Masters

Advertise

DevOpsnipp.com © 2020

medium.png