Skip to content
Snippets Groups Projects
Commit 292720ca authored by Antoine Lambert's avatar Antoine Lambert
Browse files

jobs: Add gitlab triggerable jobs configuration for incoming tags

This job will be executed when pushing tags to a swh GitLab repository
in order to generate and upload Python wheels of swh packages.

Please note that the debian packaging part has not been ported yet.

Also, wheels upload are currently disabled until we fully migrate to
GitLab.
parent b2c09ea7
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,8 @@
- "{name}/tests"
- "{name}/tests-on-diff"
- "{name}/gitlab-tests"
- "{name}/gitlab-incoming-tag"
- "{name}/gitlab-pypi-upload"
- "debian/packages/{name}"
- "debian/packages/{name}/update-for-release"
- "debian/packages/{name}/automatic-backport"
......
......@@ -6,6 +6,20 @@ pipeline {
steps {
checkout([
$class: 'GitSCM',
{%- if gitlab_project %}
userRemoteConfigs: [[
name:'origin', url: '{{gitlab_url}}/{{gitlab_project_name}}.git',
refspec: '+refs/tags/*:refs/remotes/origin/tags*'
]],
branches: [[
name: "${env.gitlabSourceBranch}"
]],
browser: [
$class: 'GitLab',
repoUrl: '{{gitlab_url}}/{{gitlab_project_name}}'
],
extensions: [[$class: 'CloneOption', honorRefspec: true]],
{%- else %}
userRemoteConfigs: [[
url: 'https://forge.softwareheritage.org/source/{{repo_name}}.git',
]],
......@@ -17,24 +31,40 @@ pipeline {
repo: '{{repo_name}}',
repoUrl: 'https://forge.softwareheritage.org/',
],
{%- endif %}
])
}
}
stage('Build and upload PyPI package') {
when {
{%- if gitlab_project %}
expression { "${env.gitlabSourceBranch}" ==~ /refs\/tags\/v\d+(.\d+)+/ }
expression { jobExists('/{{name}}/gitlab-pypi-upload') }
{%- else %}
expression { params.GIT_TAG ==~ /v\d+(.\d+)+/ }
expression { jobExists('/{{name}}/pypi-upload') }
{%- endif %}
}
steps {
build(
{%- if gitlab_project %}
job: '/{{name}}/gitlab-pypi-upload',
{%- else %}
job: '/{{name}}/pypi-upload',
{%- endif %}
parameters: [
{%- if gitlab_project %}
string(name: 'GIT_TAG', value: "${env.gitlabSourceBranch}"),
{%- else %}
string(name: 'GIT_TAG', value: params.GIT_TAG),
{%- endif %}
string(name: 'PYPI_HOST', value: '{{incoming_tag_auto_pypi_host}}'),
],
)
}
}
{%- if not gitlab_project %}
stage('Update Debian packaging for new release') {
when {
expression { params.GIT_TAG ==~ /v\d+(.\d+)+/ }
......@@ -67,5 +97,6 @@ pipeline {
)
}
}
{%- endif %}
}
}
......@@ -2,9 +2,10 @@
name: "{name}/incoming-tag"
display-name: Incoming tag
project-type: pipeline
auth-token: 'ph4br1cat0r'
auth-token: "ph4br1cat0r"
incoming_tag_auto_pypi_host: pypi.org
sandbox: true
gitlab_project: false
properties:
- build-discarder:
num-to-keep: 20
......@@ -15,11 +16,23 @@
type: PT_TAG
sortMode: DESCENDING_SMART
selectedValue: TOP
dsl:
!include-jinja2: incoming-tag.groovy.j2
dsl: !include-jinja2: incoming-tag.groovy.j2
- job-template:
name: "debian/deps/{name}/incoming-tag"
dsl:
!include-jinja2: dependency-incoming-tag.groovy.j2
dsl: !include-jinja2: dependency-incoming-tag.groovy.j2
<<: *incoming_tag
- job-template:
name: "{name}/gitlab-incoming-tag"
display-name: Incoming tag (GitLab)
gitlab_project: true
parameters:
triggers:
- gitlab:
trigger-push: true
trigger-merge-request: false
add-ci-message: true
# secret jenkins token is generated when executing tox
secret-token: !include-raw: jenkins-token
<<: *incoming_tag
......@@ -31,7 +31,11 @@ pipeline {
agent none
steps {
build(
{%- if gitlab_project %}
job: '/{{name}}/gitlab-tests',
{%- else %}
job: '/{{name}}/tests',
{%- endif %}
parameters: [
string(name: 'REVISION', value: params.GIT_TAG),
],
......@@ -42,13 +46,25 @@ pipeline {
stage('Checkout') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: params.GIT_TAG]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
gitTool: 'Default',
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://forge.softwareheritage.org/source/{{repo_name}}.git']]
checkout([
$class: 'GitSCM',
{%- if gitlab_project %}
userRemoteConfigs: [[
name:'origin', url: '{{gitlab_url}}/{{gitlab_project_name}}.git',
refspec: '+refs/tags/*:refs/remotes/origin/tags*'
]],
branches: [[
name: "${params.GIT_TAG}"
]],
extensions: [[$class: 'CloneOption', honorRefspec: true]],
{%- else %}
userRemoteConfigs: [[url: 'https://forge.softwareheritage.org/source/{{repo_name}}.git']],
branches: [[name: params.GIT_TAG]],
{%- endif %}
doGenerateSubmoduleConfigurations: false,
extensions: [],
gitTool: 'Default',
submoduleCfg: [],
])
sh '''rm -rf dist/'''
}
......@@ -82,6 +98,7 @@ pipeline {
}
}
{%- if not gitlab_project %}
stage('Publish') {
when {
anyOf {
......@@ -102,6 +119,7 @@ pipeline {
}
}
}
{%- endif %}
}
post {
cleanup {
......
- job-template:
- job-template: &pypi_upload
name: "{name}/pypi-upload"
display-name: "Upload to PyPI"
docker_image: tox
include_bdist: true
project-type: pipeline
sandbox: true
gitlab_project: false
properties:
- build-discarder:
artifact-num-to-keep: 10
- copyartifact:
projects: '*'
projects: "*"
parameters:
- git-parameter:
name: GIT_TAG
......@@ -45,8 +46,13 @@
Proceed even if the tests are failing on the repository.
- bool:
name: INCLUDE_BDIST
default: '{include_bdist}'
default: "{include_bdist}"
description: |
Include a binary distribution in the PyPI upload.
dsl:
!include-jinja2: swh-pypi.groovy.j2
dsl: !include-jinja2: swh-pypi.groovy.j2
- job-template:
name: "{name}/gitlab-pypi-upload"
display-name: "Upload to PyPI (GitLab)"
gitlab_project: true
<<: *pypi_upload
......@@ -33,6 +33,8 @@ pipeline {
def repoName= project.get('project').get('repo_name')
def gitlabProjectName = "swh/devel/${repoName}"
setupGitlabWebhook(gitlabProjectName, "${jenkinsFolder}/gitlab-tests")
setupGitlabWebhook(gitlabProjectName, "${jenkinsFolder}/gitlab-incoming-tag",
false, false, true)
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment