Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In 117 jenkins update #2985

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
IN-117: Update environment variables to support newer versions of Jen…
…kins plugins

As part of a Jenkins upgrade and plugins reconfiguration some environments
variables stopped being present or had their name changed. Due to that, the
Jenkinsfile had to be updated and old variables have been replaced to use
the new ones.

The GIT_URL variable was removed and there is no equivalent new one, so in this
case, on the environment session, we declare a new GITHUB_REPO_URL variable which
is used in place of the old one.
davialexandre committed Apr 25, 2019
commit 5a341ed20ca9fad3be7272e9900ab78dff8b66e8
14 changes: 6 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ pipeline {
WEBURL = "http://jenkins.compucorp.co.uk:8900"
KARMA_TESTS_REPORT_FOLDER = "reports/js-karma"
PHPUNIT_TESTS_REPORT_FOLDER = "reports/phpunit"
GITHUB_REPO_URL = "https://github.com/compucorp/civihr"
}

stages {
@@ -51,8 +52,8 @@ pipeline {
sh "civibuild create ${params.CIVIHR_BUILDNAME} --type drupal-clean --civi-ver 5.3.1 --url $WEBURL"

// Get target and PR branches name
def prBranch = env.CHANGE_BRANCH
def envBranch = env.CHANGE_TARGET ? env.CHANGE_TARGET : env.BRANCH_NAME
def prBranch = env.BRANCH_NAME
def envBranch = env.GITHUB_PR_TARGET_BRANCH ? env.GITHUB_PR_TARGET_BRANCH : env.BRANCH_NAME
if (prBranch != null && prBranch.startsWith("hotfix-")) {
envBranch = 'master'
}
@@ -229,7 +230,7 @@ def getBuildTargetLink() {
def link = ''
def forPR = buildIsForAPullRequest()

link = forPR ? "<${env.CHANGE_URL}|${env.CHANGE_TITLE}>" : '<' + getRepositoryUrlForBuildBranch() + '|' + env.BRANCH_NAME + '>'
link = forPR ? "<${env.GITHUB_PR_URL}|${env.GITHUB_PR_TITLE}>" : '<' + getRepositoryUrlForBuildBranch() + '|' + env.BRANCH_NAME + '>'

return link
}
@@ -238,17 +239,14 @@ def getBuildTargetLink() {
* Returns true if this build as triggered by a Pull Request.
*/
def buildIsForAPullRequest() {
return env.CHANGE_URL != null
return env.GITHUB_PR_NUMBER != null
}

/*
* Returns a URL pointing to branch currently being built
*/
def getRepositoryUrlForBuildBranch() {
def repositoryURL = env.GIT_URL
repositoryURL = repositoryURL.replace('.git', '')

return repositoryURL + '/tree/' + env.BRANCH_NAME
return env.GITHUB_REPO_URL + '/tree/' + env.BRANCH_NAME
}

/*