JobDSL custom config file - jenkins-job-dsl

I'm trying to setup a jenkins job with custom config file, original xml looks as follows (the relevant part):
<buildWrappers>
<org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider#2.11">
<managedFiles>
<org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
<fileId>30de8d2f-621d-4c51-b644-4302b548fd15</fileId>
<targetLocation>./src/</targetLocation>
<variable/>
<replaceTokens>false</replaceTokens>
</org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
</managedFiles>
</org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>
</buildWrappers>
Here's my JobDSL attempt:
job('example') {
configure{
it / 'buildWrappers' << 'org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile' {
managedFiles {
org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile{
fileId '30de8d2f-621d-4c51-b644-4302b548fd15'
targetLocation './/src//'
}
}
}
}
}
What am I missing? Thanks!

You can use the built-in DSL: https://jenkinsci.github.io/job-dsl-plugin/#path/job-wrappers-configFiles
The built-in DSL will also resolve the fileId from the file name.
job('example') {
wrappers {
configFiles {
file('myCustomConfigFile') {
targetLocation('src')
}
}
}
}

Related

Jenkins DSL Plugin (>=1.77): Use gerrit-trigger in pipelineJob

I don't know how to use the gerrit-trigger plugin in a DSL pipelineJob. According to the dsl plugin doc triggers is deprecated for pipelineJobs. And from the wiki 1.77 replaced by pipelineTriggers. So I have change my triggers section to
properties {
pipelineTriggers {
triggers {
gerrit {
events {
patchsetCreated()
}
project('**My/Git/Repo', '**')
}
}
}
}
However, when I use pipelineTriggers i get the following
ERROR: (configure_seed_jobs.groovy, line 25) No signature of method: events() is applicable for argument types: (configure_seed_jobs$_run_closure1$_closure4$_closure9$_closure10$_closure11$_closure12) values: [configure_seed_jobs$_run_closure1$_closure4$_closure9$_closure10$_closure11$_closure12#3bcd6c54]
Possible solutions: gerritProjects(), buildFailureMessage(), buildNotBuiltMessage(), buildStartMessage(), buildSuccessfulMessage(), buildUnstableMessage(), buildUnsuccessfulFilepath(), changeSubjectParameterMode(), commentTextParameterMode(), commitMessageParameterMode(), customUrl(), dependencyJobsNames(), dynamicTriggerConfiguration(), escapeQuotes(), gerritBuildFailedCodeReviewValue(), gerritBuildFailedVerifiedValue(), gerritBuildNotBuiltCodeReviewValue(), gerritBuildNotBuiltVerifiedValue(), gerritBuildStartedCodeReviewValue(), gerritBuildStartedVerifiedValue(), gerritBuildSuccessfulCodeReviewValue(), gerritBuildSuccessfulVerifiedValue(), gerritBuildUnstableCodeReviewValue(), gerritBuildUnstableVerifiedValue(), gerritSlaveId(), nameAndEmailParameterMode(), notificationLevel(), serverName(), silentMode(), silentStartMode(), skipVote(), triggerConfigURL(), triggerOnEvents()
What am I missing?
I had the same problem, because either events{..} or project() is no more available to gerrit in pipelineTriggers, you should use triggerOnEvents {..} and gettitProjects{...} instead. For more details, you could find them in the document on your jenkins (e.g. http://0.0.0.0:8080/plugin/job-dsl/api-viewer/)
properties {
pipelineTriggers {
triggers {
gerritTrigger {
gerritProjects {
gerritProject {
compareType('PLAIN')
pattern('**My/Git/Repo')
branches {
branch {
compareType('PLAIN')
pattern('master')
}
}
}
}
triggerOnEvents {
changeMerged()
}
}
}
}

Module not found on path for interface table module

I am getting the following error
Module not found on path 'GPSSim.satellite[0].interfaceTable' defined by par 'GPSSim.satellite[0].wlan[0].interfaceTableModule' -- in module (inet::InterfaceEntry) GPSSim.satellite[0].wlan[0] (id=51), during network initialization
There are a lot of code but i will show the ones that i believe is important. If more code is required do let me know, thanks!
GPSSIM.ned This file is the network file
network GPSSim
{
parameters:
int numOfSats; // Number of satellites
submodules:
satellite[numOfSats]: GPSSatellite {
parameters:
#display("p=505.835,100.085;r=10,,#707070;i=device/satellite_l");
}
}
GPSSatellite.ned
module GPSSatellite extends StandardSatellite
{
submodules:
gpsApp[numGpsApps]: <default("GPSApp")> like IGPSApp { //default("UdpApp")
parameters:
#display("p=100,284,row,60");
}
}
StandardSatellite.ned
module StandardSatellite extends Satellite
{
parameters:
#node; //because of MobilityBase initialization'
#networkNode();
int numRadios = default(1);
**.interfaceTableModule = default(absPath(".interfaceTable"));
//wlan[*].mgmt.typename = default("Ieee80211MgmtAp");
//wlan[*].interfaceTableModule = default(absPath(".interfaceEntry"));
//wlan[*].mgmtType = default("Ieee80211MgmtAdhoc"); // use adhoc management
submodules:
interfaceTable: InterfaceTable {
parameters:
#display("p=407,69");
}
routingTable: Ipv4RoutingTable {
parameters:
#display("p=45,178");
//IPForward = IPForward;
//forwardMulticast = forwardMulticast;
routingFile = routingFile;
}
wlan[numRadios]: <default("Ieee80211Interface")> like IWirelessInterface {
parameters:
#display("p=301.35,379.05;q=queue");
}
ext[numExtInterfaces]: <default("ExtInterface")> like IExternalInterface {
parameters:
#display("p=217,421,row,10;q=txQueue;i=block/ifcard");
}
networkLayer: NetworkLayerNodeBase {
parameters:
#display("p=226.8,198.45;q=queue");
}
lo0: LoopbackInterface {
#display("p=78,406");
}
App: <default("UdpBasicBurst")> like IApp {
#display("p=469.35,198.45");
}
connections allowunconnected:
wlan[0].upperLayerOut --> networkLayer.radioIn[0];
//ext[0].upperLayerOut --> networkLayer.radioIn[0];
//lo0.upperLayerOut --> networkLayer.radioIn[0];
}
When i put the interface table module in the top level network (GPSSim) instead, i don't get this error but instead i get another error where the interface is already registered which the cause is precisely because i did that, since im telling each instance of satellite to use the same interface table.
I dont' know where to go from here. Any help would be greatly appreciated! Thanks in advance.
Try change the line
**.interfaceTableModule = default(absPath(".interfaceTable"));
into:
interfaceTableModule = default("interfaceTable");
Parameter interfaceTableModule should point to the interface table in that node.

Extracting requierement properties from Capella

I would like to extract the requirements data in capella using m2doc, requirements (SystemFunctionalRequirement) are located in a "RequirementsPkg" package in System analysis, thanks to the "m:RequirementsPkg.eContents().summary" command I managed to retrieve the summary of all requirements but I would like to retrieve the name and the summary of a specific requirement.
Can you help me ?
Thanks in advance
This mechanism is deprecated. You should use the requirement extension.
Starting from the root element, you can use something like:
{ m:system.ownedArchitectures->filter(la::LogicalArchitecture).ownedRequirementPkgs.ownedRequirements.name }
With the requirement extension the easiest way is to create a service:
public List<Requirement> getRequirements(ExtensibleElement element) {
List<Requirement> res = new ArrayList<>();
for (ElementExtension extension : element.getOwnedExtensions()) {
if (extension instanceof Requirement) {
res.add((Requirement) extension);
break;
} else if (extension instanceof CapellaOutgoingRelation) {
res.add(((CapellaOutgoingRelation) extension).getTarget());
}
}
return res;
}
and call it, for instance on a diagram:
{ m:for req | '[LAB] IFE System - All Components, CEs'.representationByName().eAllContents(viewpoint::DRepresentationElement).semanticElements->filter(emde::ExtensibleElement).getRequirements() }
{ m:req.ReqIFLongName }
{ m:endfor }

Adding native static dependencies

In a C++ Gradle project, I use the boost 1.49 library.
How can I add this library as dependency of my project.
I try in this way, but I should define boost as dependency. There is a C++ library repository?
apply plugin: 'cpp'
libraries {
hello {
baseName 'hello'
}
}
sources {
hello{
cpp {
source.srcDirs = ['src']
lib library: 'boost', linkage: 'api'
exportedHeaders.srcDirs = ['include']
}
}
}
c/cpp programming is not but domain (in contrast to gradle ;) ) but when you navigate to $GRADLE_HOME/samples/native-binaries you can find lots of useful examples there.
One of them - cunit (oh, there's a another one: multi-project) has such configuration - it may be useful for you. Below I enclose build.gradle from cunit - in case you use gradle wrapper.
apply plugin: "c"
apply plugin: "cunit"
model {
flavors {
passing
failing
}
repositories {
libs(PrebuiltLibraries) {
cunit {
headers.srcDir "lib/cunit/2.1-2/include"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile =
file("lib/cunit/2.1-2/lib/" +
findCUnitLibForPlatform(targetPlatform))
}
}
}
}
}
libraries {
operators {}
}
binaries.withType(CUnitTestSuiteBinarySpec) {
lib library: "cunit", linkage: "static"
if (flavor == flavors.failing) {
cCompiler.define "PLUS_BROKEN"
}
}
def findCUnitLibForPlatform(Platform platform) {
if (platform.operatingSystem.windows) {
return "vs2010/cunit.lib"
// return "vs2013/cunit.lib"
// return "cygwin/cunit.lib"
// return "mingw/cunit.lib"
} else if (platform.operatingSystem.macOsX) {
return "osx/libcunit.a"
} else {
return "linux/libcunit.a"
}
}
Quick googling has shown that there's no such thing like a libraries repository for c/cpp projects. It seems that the libraries should be included in project sources.

get the list of source files from existing eclipse project using CDT

i am working on CDT eclipse plug in development, i am trying to get the list of sources files which exist in eclipse project explorer using CDT code using following code ,which results null.
Case1:
IFile[] files2 = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(new URI("file:/"+workingDirectory));
for (IFile file : files2) {
System.out.println("fullpath " +file.getFullPath());
}
Case2:
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(getProject().getRawLocationURI());
for (IFile file : files) {
System.out.println("fullpath " +file.getFullPath());
}
Case3:
IFile[] files3 = ResourceLookup.findFilesByName(getProject().getFullPath(),ResourcesPlugin.getWorkspace().getRoot().getProjects(),false);
for (IFile file : files3) {
System.out.println("fullpath " +file.getFullPath());
}
Case4:
IFolder srcFolder = project.getFolder("src");
Case 1 ,2,3 giving me output null, where i am expecting list of files;
in Case 4: i am getting the list of "helloworld/src" files, but i am expecting to get the files from the existing project mean main root ,ex:"helloworld"
please suggest me on this.
You can either walk through the worspace resources tree using IResourceVisitor - or you can walk through CDT model:
private void findSourceFiles(final IProject project) {
final ICProject cproject = CoreModel.getDefault().create(project);
if (cproject != null) {
try {
cproject.accept(new ICElementVisitor() {
#Override
public boolean visit(final ICElement element) throws CoreException {
if (element.getElementType() == ICElement.C_UNIT) {
ITranslationUnit unit = (ITranslationUnit) element;
if (unit.isSourceUnit()) {
System.out.printf("%s, %s, %s\n", element.getElementName(), element.getClass(), element
.getUnderlyingResource().getFullPath());
}
return false;
} else {
return true;
}
}
});
} catch (final CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Note there may be more source files then you actually want (e.g. you may not care system about headers) - you can filter them by checking what the underlying resource is.