Conda#

The purpose of this document is to make a how-to for having a conda package build on Jenkins. This document includes templates for accomplishing this goal. The first step is to create a conda recipe for a CSC. A template for doing so has been included on this page.

Creating the Recipe#

Create a conda folder inside the root directory CSC repository. Then copy the contents of the meta.yaml template into a meta.yaml file inside of the conda folder. Change the csc-name so that it becomes the name of the csc. Another thing is to add requirements so that they match the CSC’s. Keep in mind that the test requirements need to include test framework dependencies. It is suggested to sort dependencies as that increases readability of the recipe. To find the configuration repo, look for the get_config_pkg() in the CSC class.

meta.yaml#
{% set data= load_setup_py_data() %}
package:
    name: csc-name
    version: {{ data.get('version') }}

source:
    path: ../

build:
    noarch: python
    script: {{ PYTHON }} -m pip install --no-deps --ignore-installed .

test:
    requires:
        - ts-conda-build =0.3
        - ts-idl {{ idl_version }}
        - ts-salobj {{ salobj_version }}
    source_files:
        - bin
        - pyproject.toml
        - python
        - tests
    commands:
        - pytest

requirements:
    host:
        - python {{ python }}
        - setuptools
        - setuptools_scm
    build:
        - python {{ python }}
        - setuptools
        - setuptools_scm
        - ts-conda-build =0.3
    run:
        - python {{ python }}
        - setuptools
        - setuptools_scm
        - ts-idl
        - ts-salobj
        # Add any other runtime dependencies here

Locally test the recipe by running the following command

docker run -e {config_repo}=/path/to/config/repo \\
    -v /path/to/your/repos:/home/saluser/develop \\
    -it ts-dockerhub.lsst.org/conda_package_builder

Then run the following inside of the container.

cd path/to/conda/recipe
conda build --variants "{salobj_version: '', idl_version: ''}" --prefix-length 100 .

Creating the Jenkinsfile#

Once that is passing, move onto creating the Jenkinsfile.conda file. A template has been included below. It takes the following arguments

configuration_repo

A list of configuration repos, can be empty, one or many.

package_name

The name of the package.

module_namespace

This is the namespace location for the module, for the coverage extension.

arch

This is the architecture of the conda package to create. It can be linux-64 or noarch. It may be omitted and defaults to linux-64. When specifying noarch in the conda recipe, this argument must be set to noarch.

Jenkinsfile.conda#
@Library('JenkinsShared')_
CondaPipeline(["configuration_repo"], "package_name", "module_namespace", "arch")

Adding the Job#

Add the job by creating a new item on the Jenkins server and selecting Multibranch Pipeline.

../../_images/jenkins-conda-adding-the-job-0.png

In Branch Sources click the github source selection and type in the path of the repo into the Respository HTTPS URL.

../../_images/jenkins-conda-adding-the-job-1.png

Then in the behaviors subsection click the add button and find the Custom GitHub Notification Context behavior.

../../_images/jenkins-conda-adding-the-job-2.png

Check the Apply Suffix box and in the label field add /conda to the end of the value.

Then in Build strategies click the add button and find the Tags strategies and leave the default values.

../../_images/jenkins-conda-adding-the-job-3.png

Then in Build Configuration add .conda to the Script Path field.

../../_images/jenkins-conda-adding-the-job-4.png

Then click Apply and Save.

Warning

If your job has a build strategy for regular branches, remove it as these jobs are not yet ready to be run on PR or branches.