Jenkins REST API smoke test

文章目录

  • 使用`curl`命令测试REST API

使用curl命令测试REST API

Execute Shell:

curl -vso out.json http://192.168.87.155:10080/greeting
if [ -z $(cat out.json | grep "Hello") ] ; then
    echo "Smoke test failed."
    exit 1
fi

Jenkins Pipeline:

stage('Smoke Test') {
    steps {
        echo "Smoke Test: API service"
        sh '''
            curl -vso out.json http://192.168.87.155:10080/api/test/?format=json
            if [ -z $(cat out.json | grep 'test') ] ; then
                echo "API service smoke test failed."
                exit 1
            fi
        '''
    }
}

你可能感兴趣的:(Jenkins)