Skip to content

Commit

Permalink
feat(jenkins): Allow to specify a VCS path for configuration
Browse files Browse the repository at this point in the history
For cases where ORT configuration for different projects is managed in
different paths of a single repository, allow to specify the path. This
allows to easily maintain a layout like

    root
    |
    +- license-classifications.yml
    |
    +- project-a
    |  |
    |  +- evaluator.rules.kts
    |  |
    |  +- license-classifications.yml -> ../license-classifications.yml
    |
    +- project-b
       |
       +- evaluator.rules.kts
       |
       +- license-classifications.yml -> ../license-classifications.yml

with complete configuration in project-specific directories and common
configuration symbolically linked into those directories.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Nov 22, 2023
1 parent 333d1d7 commit 1e4a20c
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions integrations/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ pipeline {
defaultValue: ''
)

string(
name: 'ORT_CONFIG_VCS_PATH',
description: 'Optional VCS path of the ORT configuration.',
defaultValue: ''
)

credentials(
name: 'ORT_CONFIG_VCS_CREDENTIALS',
credentialType: 'com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl',
Expand Down Expand Up @@ -334,25 +340,31 @@ pipeline {
rm -fr $ORT_DATA_DIR/config
/opt/ort/bin/ort $ORT_OPTIONS download --project-url $ORT_CONFIG_VCS_URL $VCS_REVISION_OPTION -o $ORT_DATA_DIR/config
if [ -f "$ORT_DATA_DIR/config/config.yml" ]; then
echo "Not creating '$ORT_DATA_DIR/config/config.yml' as it already exists."
else
echo "Creating '$ORT_DATA_DIR/config/config.yml' template for job parameters."
cat >$ORT_DATA_DIR/config/config.yml <<EOF
ort:
packageCurationProviders:
- name: DefaultFile
- name: DefaultDir
- name: OrtConfig
enabled: ${USE_ORT_CONFIG_CURATIONS}
- name: ClearlyDefined
enabled: ${USE_CLEARLY_DEFINED_CURATIONS}
EOF
fi
rm -f $HOME/.netrc
'''.stripIndent().trim()
}

script {
env.ORT_CONFIG_DIR = "${env.ORT_DATA_DIR}/config/${env.ORT_CONFIG_VCS_PATH}"
}

sh '''
if [ -f "$ORT_CONFIG_DIR/config.yml" ]; then
echo "Not creating '$ORT_CONFIG_DIR/config.yml' as it already exists."
else
echo "Creating '$ORT_CONFIG_DIR/config.yml' template for job parameters."
cat >$ORT_CONFIG_DIR/config.yml <<EOF
ort:
packageCurationProviders:
- name: DefaultFile
- name: DefaultDir
- name: OrtConfig
enabled: ${USE_ORT_CONFIG_CURATIONS}
- name: ClearlyDefined
enabled: ${USE_CLEARLY_DEFINED_CURATIONS}
EOF
fi
'''.stripIndent().trim()
}
}

Expand Down

0 comments on commit 1e4a20c

Please sign in to comment.