You need to sign in or sign up before continuing.
Newer
Older
def branch = "master"
if (env.gitlabMergeRequestIid) {
branch = "merge-requests/${env.gitlabMergeRequestIid}"
} else if (env.gitlabSourceBranch) {
branch = env.gitlabSourceBranch
}
agent {
label "built-in"
}
stages {
stage('Checkout Repository') {
steps {
updateGitlabCommitStatus name: 'jenkins', state: 'running'
checkout([
$class: 'GitSCM',
branches: [[name: branch]],
userRemoteConfigs: [[
url: '{{gitlab_url}}/{{gitlab_project_name}}.git',
refspec: '+refs/heads/*:refs/remotes/origin/* \
+refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*'
]],
])
}
}
stage('Test Jenkins jobs can be generated') {
steps {
sh('tox')
}
}
stage('Update Jenkins jobs and setup gitlab webhooks') {
when {
// really update jenkins jobs configuration when pushing commits to master
// or when manually triggering the job from Jenkins UI
anyOf {
expression { "${env.gitlabActionType}" == "PUSH" && "${env.gitlabBranch}" == "master" }
expression { !env.gitlabActionType }
sh('tox -- update --delete-old --jobs-only')
job: '/jenkins-tools/setup-gitlab-webhooks'
{% filter indent(width=4) %}
{%- include 'jobs/templates/includes/update-gitlab-commit-status.groovy.j2' -%}
{% endfilter %}