Skip to content

Commit

Permalink
Jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed May 18, 2017
1 parent f1e8da0 commit 9e0ea24
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
Binary file added images/jenkins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions integrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Integrations
integrations/premake
integrations/qbs
integrations/git
integrations/jenkins
integrations/travisci
integrations/appveyor
integrations/gitlab
Expand Down
118 changes: 118 additions & 0 deletions integrations/jenkins.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@

|jenkins_logo| Jenkins
=============================

You can use `Jenkins CI` both for:

- Building and testing your project, which manages dependencies with Conan, and probably a conanfile.txt file
- Building and testing conan binary packages for a given conan package recipe (with a conanfile.py)

There is no needed any special setup for it, just install conan and your build tools in the Jenkins machine and call
the needed ``conan`` commands.


Artifactory and Jenkins integration
___________________________________


If you are using `Artifactory`_ you can take advantage of the `Jenkins Artifactory Plugin`_.
Check `here how to install the plugin`_ and `here you can check the full documentation about the DSL`_.

The Artifactory Jenkins plugin provides a powerful DSL language to call conan, connect with your Artifactory instance,
upload and download your packages from Artifactory and manage your `build information`_.



Example: Test your project getting requirements from Artifactory
****************************************************************

This is a template to use Jenkins with Artifactory plugin and Conan to retrieve your package from Artifactory server
and publish the `build information`_ about the downloaded packages to Artifactory.

In this script we assume that we already have all our dependencies in the Artifactory server, and we are building
our project that uses **Boost** and **Poco** libraries.

Create a new Jenkins Pipeline task using this script:


.. code-block:: groovy
//Adjust your artifactory instance name/repository and your source code repository
def artifactory_name = "artifactory"
def artifactory_repo = "conan-local"
def repo_url = 'https://github.com/memsharded/example-boost-poco.git'
def repo_branch = 'master'
node {
stage("Get project"){
git branch: repo_branch, url: repo_url
}
stage("Configure Artifactory/Conan")
def server = Artifactory.server artifactory_name
def client = Artifactory.newConanClient()
def serverName = client.remote.add server: server, repo: artifactory_repo
// You could optionally don't remove the default conan.io server to retrieve from conan.io
client.run(command: "remote remove conan.io")
stage("Get dependencies and publish build info"){
sh "mkdir -p build"
dir ('build') {
def b = client.run(command: "install ..")
server.publishBuildInfo b
}
}
stage("Build/Test project"){
dir ('build') {
sh "cmake ../ && cmake --build ."
}
}
}
Example: Build a conan package and upload it to Artifactory
***********************************************************

In this example we will call conan :ref:`test package<creating_and_testing_packages>` command to create a binary package
and then upload it to Artifactory. We also upload the `build information`_:


.. code-block:: groovy
def artifactory_name = "artifactory"
def artifactory_repo = "conan-local"
def repo_url = 'https://github.com/lasote/conan-libcurl.git'
def repo_branch = "release/7.50.3"
node {
stage("Get recipe"){
git branch: repo_branch, url: repo_url
}
stage("Configure Artifactory/Conan")
def server = Artifactory.server artifactory_name
def client = Artifactory.newConanClient()
def serverName = client.remote.add server: server, repo: artifactory_repo
client.run(command: "remote remove conan.io")
stage("Test recipe"){
client.run(command: "test_package")
}
stage("Upload packages"){
String command = "upload * --all -r ${serverName} --confirm"
def b = client.run(command: command)
server.publishBuildInfo b
}
}
.. |jenkins_logo| image:: ../images/jenkins.png
.. _`Artifactory`: https://www.jfrog.com/artifactory/
.. _`Jenkins Artifactory Plugin`:
.. _`here how to install the plugin`: https://www.jfrog.com/confluence/display/RTF/Jenkins+%28Hudson%29+Artifactory+Plug-in
.. _`here you can check the full documentation about the DSL`: https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+-+Working+With+the+Pipeline+Jenkins+Plugin
.. _`build information`: https://www.jfrog.com/confluence/display/RTF/Build+Integration
1 change: 1 addition & 0 deletions packaging/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ The main differences with the above ``conanfile.py`` are:
- The ``test()`` method specifies which binaries have to be run.
- The ``imports()`` method is defined to copy shared libraries to the ``bin`` folder, so when dynamic linkage is used, and the ``test()`` method launches the ``example`` executable, they are found and ``example`` runs.

.. _creating_and_testing_packages:

Creating and testing packages
-------------------------------
Expand Down

0 comments on commit 9e0ea24

Please sign in to comment.