From 95f5a24aa815fae8b3c135bf55f1f1a4c262ee94 Mon Sep 17 00:00:00 2001 From: PengTian0 Date: Tue, 8 Aug 2017 03:58:27 -0400 Subject: [PATCH] initial commit --- .../rackhd/source_code/UnitTest.groovy | 40 +++++++++++++++++++ workflows/pr_gate/Jenkinsfile | 23 +++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/pipeline/rackhd/source_code/UnitTest.groovy create mode 100644 workflows/pr_gate/Jenkinsfile diff --git a/src/pipeline/rackhd/source_code/UnitTest.groovy b/src/pipeline/rackhd/source_code/UnitTest.groovy new file mode 100644 index 0000000..47643e6 --- /dev/null +++ b/src/pipeline/rackhd/source_code/UnitTest.groovy @@ -0,0 +1,40 @@ +package pipeline.rackhd.source_code + +def runTest(manifest_dict, repo_name){ + /* + manifest is a map contains manifest stash name and stash path: + {"stash_name":xxx, + "stash_path":xxx} + repo_name is a String which is the name of the repository + */ + def shareMethod = new pipeline.common.ShareMethod() + String label_name="unittest" + lock(label:label_name,quantity:1){ + node_name = shareMethod.occupyAvailableLockedResource(label_name, []) + node(node_name){ + deleteDir() + String on_build_config_dir = "$WORKSPACE/on-build-config" + shareMethod.checkoutOnBuildConfig(on_build_config_dir) + String manifest_name = manifest_dict["stash_name"] + unstash "$manifest_name" + String manifest_path = "$WORKSPACE/" + manifest_dict["stash_path"] + def manifest = new pipeline.common.Manifest() + String repo_dir = manifest.checkoutTargetRepo(manifest_path, repo_name, on_build_config_dir) + try{ + sh """#!/bin/bash -ex + pushd $repo_dir + ./HWIMO-TEST + popd + """ + } finally{ + dir(repo_dir){ + junit "*.xml" + archiveArtifacts "*.xml" + } + } + } + } +} + +return this + diff --git a/workflows/pr_gate/Jenkinsfile b/workflows/pr_gate/Jenkinsfile new file mode 100644 index 0000000..d745960 --- /dev/null +++ b/workflows/pr_gate/Jenkinsfile @@ -0,0 +1,23 @@ +@Library('my_library') _ +node{ + timestamps{ + def manifest = new pipeline.common.Manifest() + def unit_test = new pipeline.rackhd.source_code.UnitTest() + + manifest.downloadManifest("https://dl.bintray.com/rackhd/binary/master-20170806","master-20170806") + stash name: "prgate_manifest", includes: "master-20170806" + manifest_dict = [:] + manifest_dict["stash_name"] = "prgate_manifest" + manifest_dict["stash_path"] = "master-20170806" + stage("Unit Test"){ + def unit_test_branches = [:] + unit_test_branches["on-core"] = { + unit_test.runTest(manifest_dict, "on-core") + } + unit_test_branches["on-tasks"] = { + unit_test.runTest(manifest_dict, "on-tasks") + } + parallel unit_test_branches + } + } +}