コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Jenkins】Jenkins Pipeline でステージごとにタイムアウトを設定する方法

概要

方法1

pipeline {
    agent any

    stages {
        stage("Hello") {
            steps {
                script {
                    timeout(time: 5, unit: "SECONDS") {
                        sleep 10
                        echo "Hello World"
                    }
                }
            }
        }
    }
}

方法2

pipeline {
    agent any

    stages {
        stage("Hello") {
            options {
                timeout(time: 5, unit: "SECONDS")
            }
            steps {
                sleep 10
                echo "Hello World"
            }
        }
    }
}

備考

タイムアウトした場合のリザルトは Aborted になる

参考サイト様