-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package pipeline.common | ||
import java.io.File; | ||
|
||
def downloadManifest(String url, String target){ | ||
withCredentials([ | ||
usernamePassword(credentialsId: 'a94afe79-82f5-495a-877c-183567c51e0b', | ||
passwordVariable: 'BINTRAY_API_KEY', | ||
usernameVariable: 'BINTRAY_USERNAME') | ||
]){ | ||
sh 'curl --user $BINTRAY_USERNAME:$BINTRAY_API_KEY --retry 5 --retry-delay 5 ' + "$url" + ' -o ' + "${target}" | ||
} | ||
} | ||
|
||
def stashManifest(String manifest_name, String manifest_path){ | ||
stash name: "$manifest_name", includes: "$manifest_path" | ||
manifest_dict = [:] | ||
manifest_dict["stash_name"] = "manifest_name" | ||
manifest_dict["stash_path"] = "manifest_path" | ||
return manifest_dict | ||
} | ||
|
||
def unstashManifest(Map manifest_dict, String target_dir){ | ||
String manifest_name = manifest_dict["stash_name"] | ||
String manifest_path = manifest_dict["stash_path"] | ||
dir(target_dir){ | ||
unstash "$manifest_name" | ||
} | ||
manifest_path = target_dir + File.separator + manifest_path | ||
return manifest_path | ||
} | ||
|
||
def checkoutTargetRepo(String manifest_path, String repo_name, String on_build_config_dir){ | ||
sh """#!/bin/bash -ex | ||
pushd $on_build_config_dir | ||
./build-release-tools/HWIMO-BUILD ./build-release-tools/application/reprove.py \ | ||
--manifest ${manifest_path} \ | ||
--builddir ${WORKSPACE}/build-deps \ | ||
--jobs 8 \ | ||
--force \ | ||
checkout \ | ||
packagerefs | ||
""" | ||
String repo_dir = "${WORKSPACE}/build-deps/$repo_name" | ||
return repo_dir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package pipeline.common | ||
|
||
def checkout(String url, String branch, String targetDir){ | ||
checkout( | ||
[$class: 'GitSCM', branches: [[name: branch]], | ||
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: targetDir]], | ||
userRemoteConfigs: [[url: url]]]) | ||
} | ||
def checkout(String url, String branch){ | ||
checkout( | ||
[$class: 'GitSCM', branches: [[name: branch]], | ||
userRemoteConfigs: [[url: url]]]) | ||
} | ||
|
||
def checkout(String url){ | ||
checkout(url, "master") | ||
} | ||
|
||
def checkoutOnBuildConfig(String target_dir){ | ||
String scm_url = scm.getUserRemoteConfigs()[0].getUrl() | ||
if(scm_url.contains("on-build-config")){ | ||
dir(target_dir){ | ||
checkout scm | ||
} | ||
}else { | ||
checkout("https://github.com/RackHD/on-build-config", master, target_dir) | ||
} | ||
} | ||
|
||
def getLockedResourceName(String label_name){ | ||
// Get the resource name whose label contains the parameter label_name | ||
// The locked resources of the build | ||
def resources=org.jenkins.plugins.lockableresources.LockableResourcesManager.class.get().getResourcesFromBuild(currentBuild.getRawBuild()) | ||
def resources_name=[] | ||
for(int i=0;i<resources.size();i++){ | ||
String labels = resources[i].getLabels(); | ||
List label_names = Arrays.asList(labels.split("\\s+")); | ||
for(int j=0;j<label_names.size();j++){ | ||
if(label_names[j]==label_name){ | ||
resources_name.add(resources[i].getName()); | ||
} | ||
} | ||
} | ||
return resources_name | ||
} | ||
|
||
def occupyAvailableLockedResource(String label_name, ArrayList<String> used_resources){ | ||
// The locked resources whose label contains the parameter label_name | ||
resources = getLockedResourceName(label_name) | ||
def available_resources = resources - used_resources | ||
if(available_resources.size > 0){ | ||
used_resources.add(available_resources[0]) | ||
String resource_name = available_resources[0] | ||
return resource_name | ||
} | ||
else{ | ||
error("There is no available resources for $label_name") | ||
} | ||
} | ||
|
||
def parseJsonResource(String resource_path){ | ||
def json_text = libraryResource(resource_path) | ||
def props = readJSON text: json_text | ||
return props | ||
} | ||
|
||
return this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters