Skip to content

Multibranch pipeline job example #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
# incubator-nuttx-testing

Tools and configuration for NuttX testing.

## Jenkins pipeline shared library

The repository root contains the structure needed for a [Jenkins pipeline shared library](https://jenkins.io/doc/book/pipeline/shared-libraries/) to define the continuous integration pipeline outside of the [main NuttX repository](https://github.com/maht/incubator-nuttx). To be used from the main repo the following Jenkinsfile has to be defined:

```groovy
@Library('incubator-nuttx-testing') _

runContinuousIntegrationPipeline()
```

## Jenkins multibranch pipeline job creation/update

The repository contains a definition of a multibranch pipeline job called 'incubator-nuttx' and some scripts to create and update it.

Copy the `setup-example.sh` to `setup.sh` and edit proper values inside for Jenkins user, password and URL.

Then source it with '. setup.sh' and execute 'jobs/incubator-nuttx/create.sh' or 'jobs/incubator-nuttx/update.sh' to create/update the multibranch pipepline job.
20 changes: 20 additions & 0 deletions bin/jenkins-job-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

curl -X POST -H "Content-Type:text/xml" -u $JENKINS_USER:$JENKINS_TOKEN $JENKINS_URL/createItem?name=$1 --data-binary @$2
20 changes: 20 additions & 0 deletions bin/jenkins-job-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

curl -X POST -H "Content-Type:text/xml" -u $JENKINS_USER:$JENKINS_TOKEN $JENKINS_URL/job/$1/config.xml --data-binary @$2
100 changes: 100 additions & 0 deletions jobs/incubator-nuttx/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version='1.1' encoding='UTF-8'?>
<org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject plugin="workflow-multibranch@2.21">
<actions/>
<description>Apache NuttX is a mature, real-time embedded operating system (RTOS)</description>
<displayName>github.com/apache/incubator-nuttx</displayName>
<properties>

<!-- Define the 'incubator-nuttx-testing' pipeline shared library -->
<org.jenkinsci.plugins.workflow.libs.FolderLibraries plugin="workflow-cps-global-lib@2.15">
<libraries>
<org.jenkinsci.plugins.workflow.libs.LibraryConfiguration>
<name>incubator-nuttx-testing</name>
<retriever class="org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever">
<scm class="jenkins.plugins.git.GitSCMSource" plugin="git@4.1.0">
<id>fc5d10d0-6dc2-4461-b86f-789e065ff31a</id>
<remote>https://github.com/apache/incubator-nuttx-testing</remote>
<credentialsId></credentialsId>
<traits>
<jenkins.plugins.git.traits.BranchDiscoveryTrait/>
</traits>
</scm>
</retriever>
<defaultVersion>master</defaultVersion>
<implicit>false</implicit>
<allowVersionOverride>true</allowVersionOverride>
<includeInChangesets>true</includeInChangesets>
</org.jenkinsci.plugins.workflow.libs.LibraryConfiguration>
</libraries>
</org.jenkinsci.plugins.workflow.libs.FolderLibraries>

<org.jenkinsci.plugins.pipeline.modeldefinition.config.FolderConfig plugin="pipeline-model-definition@1.5.0">
<dockerLabel></dockerLabel>
<registry plugin="docker-commons@1.16"/>
</org.jenkinsci.plugins.pipeline.modeldefinition.config.FolderConfig>
</properties>

<!--
<folderViews class="jenkins.branch.MultiBranchProjectViewHolder" plugin="branch-api@2.5.5">
<owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
</folderViews>
<healthMetrics>
<com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric plugin="cloudbees-folder@6.11">
<nonRecursive>false</nonRecursive>
</com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric>
</healthMetrics>
<icon class="jenkins.branch.MetadataActionFolderIcon" plugin="branch-api@2.5.5">
<owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
</icon>
<orphanedItemStrategy class="com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy" plugin="cloudbees-folder@6.11">
<pruneDeadBranches>true</pruneDeadBranches>
<daysToKeep>-1</daysToKeep>
<numToKeep>-1</numToKeep>
</orphanedItemStrategy>
<triggers/>
<disabled>false</disabled>
-->

<!-- Define the 'incubator-nuttx' as branch source -->
<sources class="jenkins.branch.MultiBranchProject$BranchSourceList" plugin="branch-api@2.5.5">
<data>
<jenkins.branch.BranchSource>
<source class="org.jenkinsci.plugins.github_branch_source.GitHubSCMSource" plugin="github-branch-source@2.5.8">
<id>60f79c1d-0584-426c-86ae-7113a6a5bc7b</id>
<apiUri>https://api.github.com</apiUri>
<repoOwner>apache</repoOwner>
<repository>incubator-nuttx</repository>
<repositoryUrl>https://github.com/apache/incubator-nuttx</repositoryUrl>
<traits>
<org.jenkinsci.plugins.github__branch__source.BranchDiscoveryTrait>
<strategyId>1</strategyId>
</org.jenkinsci.plugins.github__branch__source.BranchDiscoveryTrait>
<org.jenkinsci.plugins.github__branch__source.OriginPullRequestDiscoveryTrait>
<strategyId>1</strategyId>
</org.jenkinsci.plugins.github__branch__source.OriginPullRequestDiscoveryTrait>
<org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait>
<strategyId>1</strategyId>
<trust class="org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission"/>
</org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait>
<jenkins.plugins.git.traits.CleanBeforeCheckoutTrait plugin="git@4.1.1">
<extension class="hudson.plugins.git.extensions.impl.CleanBeforeCheckout">
<deleteUntrackedNestedRepositories>true</deleteUntrackedNestedRepositories>
</extension>
</jenkins.plugins.git.traits.CleanBeforeCheckoutTrait>
</traits>
</source>
<strategy class="jenkins.branch.DefaultBranchPropertyStrategy">
<properties class="empty-list"/>
</strategy>
</jenkins.branch.BranchSource>
</data>
<owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
</sources>

<!-- Define the 'tools/Jenkinsfile' as Jenkinsfile's path -->
<factory class="org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory">
<owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
<scriptPath>tools/Jenkinsfile</scriptPath>
</factory>

</org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject>
21 changes: 21 additions & 0 deletions jobs/incubator-nuttx/create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

PATH=$(dirname $0)/../../bin:$PATH
jenkins-job-create.sh incubator-nuttx $(dirname $0)/config.xml
21 changes: 21 additions & 0 deletions jobs/incubator-nuttx/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

PATH=$(dirname $0)/../../bin:$PATH
jenkins-job-update.sh incubator-nuttx $(dirname $0)/config.xml
28 changes: 28 additions & 0 deletions qemu-example/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM px4io/px4-dev-nuttx:2020-01-08

RUN git clone https://github.com/apache/incubator-nuttx nuttx \
&& git clone https://github.com/apache/incubator-nuttx-apps apps

RUN cd nuttx \
&& git checkout nuttx-8.2

RUN cd apps \
&& git checkout nuttx-8.2

RUN cd nuttx \
&& tools/configure.sh lm3s6965-ek:nsh \
&& mv .config .config_lm3s6965-ek_nsh

COPY config-lm3s6965evb nuttx/.config

RUN cd nuttx \
&& make

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
qemu-system-arm \
&& apt-get -y autoremove \
&& apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*

CMD ["/usr/bin/qemu-system-arm","-M","lm3s6965evb","-kernel","/nuttx/nuttx","-serial","mon:stdio","-append","'console=ttyS0'","-nographic"]
20 changes: 20 additions & 0 deletions qemu-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# QEMU example

This is an example of running NuttX on QEMU.

## Usage

The Docker image downloads NuttX 8.2 and setup it for lm3s6965-ek:nsh configuration, adding some modifications to allow run it in QEMU using lm3s6965evb.

It can be build with `docker build -t nuttx docker` from repo root.

Also, an `expect` script has been added to show how use it in an automated way.

## Notes

The default config was modified:

* `CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT` is not set
* `CONFIG_ARMV7M_OABI_TOOLCHAIN` is not set, and instead `CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y` is used.
* `CONFIG_NSH_NETINIT=y` is used to avoid NSH wait for network initialization

Loading