diff --git a/application/overlay/Jenkinsfile.twig b/application/overlay/Jenkinsfile.twig index e1a7e34..974eaf6 100644 --- a/application/overlay/Jenkinsfile.twig +++ b/application/overlay/Jenkinsfile.twig @@ -1,28 +1,43 @@ {% set blocks = 'application/overlay/_twig/Jenkinsfile/' %} -def failureMessages = [] -pipeline { - agent { label 'linux-amd64' } - environment { - COMPOSE_DOCKER_CLI_BUILD = {{ @('jenkins.docker.buildkit.enabled') ? '1' : '0' }} - DOCKER_BUILDKIT = {{ @('jenkins.docker.buildkit.enabled') ? '1' : '0' }} - {% if @('jenkins.credentials.my127ws_key') %} - MY127WS_KEY = credentials('{{ @('jenkins.credentials.my127ws_key') }}') - {% endif %} - MY127WS_ENV = "pipeline" - } - triggers { cron(env.BRANCH_NAME == '{{ @('git.default_branch') }}' ? 'H H(2-6) * * 1' : '') } - stages { -{% include blocks ~ 'stages.twig' %} +{% extends blocks ~ 'base.twig' %} + +{# +{% block agent %} + agent { + docker { + label 'linux-amd64' + alwaysPull true + image 'quay.io/inviqa_images/workspace:latest' + args '--group-add docker --entrypoint "" --volume /var/run/docker.sock:/var/run/docker.sock --volume "$HOME/.my127:/root/.my127"' + } } - post { -{% if @('jenkins.notifications.slack.channel') and @('jenkins.notifications.slack.token_credential_id') %} - failure { -{% include blocks ~ 'slack-notification.twig' %} +{% endblock %} + +{% block stages %} + stage('Build, Test') { + when { + anyOf { + triggeredBy 'TimerTrigger' + allOf { + not { branch 'main' } + } + } + } + stages { + {% include blocks ~ 'stages-build-test.twig' %} + } } -{% endif %} - always { - sh 'ws destroy' - cleanWs() + stage('Publish, Release') { + when { + not { triggeredBy 'TimerTrigger' } + anyOf { + branch 'develop' + branch 'main' + } + } + stages { + {% include blocks ~ 'stages-publish-release.twig' %} + } } - } -} +{% endblock %} +#} diff --git a/application/overlay/_twig/Jenkinsfile/base.twig b/application/overlay/_twig/Jenkinsfile/base.twig new file mode 100644 index 0000000..a79385d --- /dev/null +++ b/application/overlay/_twig/Jenkinsfile/base.twig @@ -0,0 +1,33 @@ +{% set blocks = 'application/overlay/_twig/Jenkinsfile/' %} +def failureMessages = [] +pipeline { +{% block agent %} + agent { label 'linux-amd64' } +{% endblock %} + environment { +{% block environment %} + COMPOSE_DOCKER_CLI_BUILD = {{ @('jenkins.docker.buildkit.enabled') ? '1' : '0' }} + DOCKER_BUILDKIT = {{ @('jenkins.docker.buildkit.enabled') ? '1' : '0' }} + {% if @('jenkins.credentials.my127ws_key') %} + MY127WS_KEY = credentials('{{ @('jenkins.credentials.my127ws_key') }}') + {% endif %} + MY127WS_ENV = "pipeline" +{% endblock %} + } + triggers { cron(env.BRANCH_NAME == '{{ @('git.default_branch') }}' ? 'H H(2-6) * * 1' : '') } + stages { +{% block stages %} +{% include blocks ~ 'stages-build-test.twig' %} +{% include blocks ~ 'stages-publish-release.twig' %} +{% endblock %} + } + post { +{% block post %} +{% include blocks ~ 'slack-notification.twig' %} + always { + sh 'ws destroy' + cleanWs() + } +{% endblock %} + } +} diff --git a/application/overlay/_twig/Jenkinsfile/stages.twig b/application/overlay/_twig/Jenkinsfile/stages-build-test.twig similarity index 81% rename from application/overlay/_twig/Jenkinsfile/stages.twig rename to application/overlay/_twig/Jenkinsfile/stages-build-test.twig index 24030f0..20340a7 100644 --- a/application/overlay/_twig/Jenkinsfile/stages.twig +++ b/application/overlay/_twig/Jenkinsfile/stages-build-test.twig @@ -9,6 +9,3 @@ {% include blocks ~ 'stages/build.twig' %} {% include blocks ~ 'stages/test.twig' %} {% endif %} - -{% include blocks ~ 'stages/publish.twig' %} -{% include blocks ~ 'stages/deploy.twig' %} diff --git a/application/overlay/_twig/Jenkinsfile/stages-publish-release.twig b/application/overlay/_twig/Jenkinsfile/stages-publish-release.twig new file mode 100644 index 0000000..66308fe --- /dev/null +++ b/application/overlay/_twig/Jenkinsfile/stages-publish-release.twig @@ -0,0 +1,2 @@ +{% include blocks ~ 'stages/publish.twig' %} +{% include blocks ~ 'stages/deploy.twig' %}