diff --git a/jobs/templates/swh-pypi.groovy.j2 b/jobs/templates/swh-pypi.groovy.j2 index 282f910..0b35403 100644 --- a/jobs/templates/swh-pypi.groovy.j2 +++ b/jobs/templates/swh-pypi.groovy.j2 @@ -1,112 +1,95 @@ def module_name = '{{repo_name}}'.replace('-', '.') def PYPI_UPLOAD_HOST switch (params.PYPI_HOST) { case 'pypi.org': PYPI_UPLOAD_HOST = 'upload.pypi.org' break default: PYPI_UPLOAD_HOST = params.PYPI_HOST break } pipeline { {% filter indent(width=2) %} {%- include 'includes/agent-docker.groovy.j2' -%} {% endfilter %} stages { stage('Run tests') { when { expression { return !params.SKIP_TESTS } beforeAgent true } agent none steps { build( job: '/{{name}}/tests', parameters: [ string(name: 'REVISION', value: params.GIT_TAG), ], propagate: !params.IGNORE_TESTS, ) } } - stage('Run cypress tests') { - when { - expression { '{{repo_name}}' == 'swh-web' && !params.SKIP_TESTS } - beforeAgent true - } - agent none - steps { - build( - job: '/{{name}}/cypress', - parameters: [ - string(name: 'REVISION', value: params.GIT_TAG), - ], - propagate: !params.IGNORE_TESTS, - ) - } - } - 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']] ]) } } stage('Build') { steps { sh ''' # Build javascript assets if [ -f yarn.lock ]; then yarn install --frozen-lockfile yarn build fi # Build java assets if [ -d java ]; then for pom in $( find java/ -name pom.xml ) ; do mvn -f $pom compile assembly:single done fi python3 setup.py sdist bdist_wheel ''' archiveArtifacts allowEmptyArchive: true, artifacts: 'dist/*', fingerprint: true } } stage('Publish') { when { anyOf { expression { return params.FORCE_UPLOAD } expression { LASTV=sh(returnStdout: true, script:"curl -s https://${params.PYPI_HOST}/pypi/${module_name}/json | jq -r .info.version || true").trim() return 'v'+LASTV != params.GIT_TAG } } } steps { withCredentials([ usernamePassword(credentialsId: PYPI_UPLOAD_HOST, usernameVariable: 'TWINE_USERNAME', passwordVariable: 'TWINE_PASSWORD')]) { sh "python3 -m twine upload --repository-url https://${PYPI_UPLOAD_HOST}/legacy/ dist/*" } } } } }