-
Notifications
You must be signed in to change notification settings - Fork 6
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
Improve how directories are specfied in Jenkinsfile #955
Draft
arteymix
wants to merge
4
commits into
development
Choose a base branch
from
feature-improve-dirs-in-jenkins-build
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
67da12e
Improve how directories are specfied in Jenkinsfile
arteymix 067443d
Separate slow unit tests from integration tests
arteymix d29e115
Fix typo for the parallel stage name
arteymix 6ea00a2
Send a Slack message when Gemma is deployed to production
arteymix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
def testdbUrl | ||
def gemmaVersion | ||
def baseCodeVersion | ||
// TODO: move those into environment variables supplied by Jenkins | ||
def siteDir = '/space/web/maven-sites' | ||
def dataDir = '/space/gemmaData' | ||
def deployDir = '/var/local/tomcat/gemma' | ||
def cliDir = '/space/grp/gemma-cli' | ||
def productionDeployDir = 'moe:/var/local/tomcat/gemma' | ||
def productionDataDir = '/space/gemmaData' | ||
def developmentDeployDir = 'chalmers:/var/local/tomcat/gemma' | ||
def developmentDataDir = '/space/sandboxgemmaData' | ||
def stagingDeployDir = 'chalmers:/var/local/tomcat/gemma-staging' | ||
def stagingDataDir = '/space/staginggemmaData' | ||
def productionCliDir = '/space/grp/gemma-cli' | ||
|
||
def gemmaVersion | ||
def testdbUrl | ||
def dataDir | ||
def gemmaSiteDir | ||
def baseCodeSiteDir | ||
def deployDir | ||
def cliDir | ||
|
||
void setBuildStatus(String context, String message, String state) { | ||
step([ | ||
|
@@ -35,6 +45,7 @@ pipeline { | |
if (env.BRANCH_NAME == "development" && !gemmaVersion.endsWith("-SNAPSHOT")) { | ||
error("A development build must have a -SNAPSHOT suffix.") | ||
} | ||
def baseCodeVersion | ||
for (dep in pom.dependencies) { | ||
if (dep.groupId == 'baseCode' && dep.artifactId == 'baseCode') { | ||
baseCodeVersion = dep.version | ||
|
@@ -44,22 +55,22 @@ pipeline { | |
if (baseCodeVersion == null) { | ||
error('The baseCode dependency was not found in pom.xml.') | ||
} | ||
if (env.BRANCH_NAME == 'development') { | ||
dataDir = '/space/sandboxgemmaData' | ||
} | ||
if (env.BRANCH_NAME =~ '^(hotfix|release)-.*') { | ||
dataDir = '/space/staginggemmaData' | ||
} | ||
gemmaSiteDir = siteDir + '/gemma/gemma-' + gemmaVersion | ||
baseCodeSiteDir = siteDir + '/baseCode/baseCode-' + baseCodeVersion | ||
if (env.BRANCH_NAME == 'master') { | ||
deployDir = 'moe:' + deployDir | ||
dataDir = productionDataDir | ||
deployDir = productionDeployDir | ||
cliDir = productionCliDir | ||
} else if (env.BRANCH_NAME == 'development') { | ||
dataDir = developmentDataDir | ||
deployDir = developmentDeployDir | ||
// no CLI should be deployed | ||
} else if (env.BRANCH_NAME =~ '^(hotfix|release)-.*') { | ||
dataDir = stagingDataDir | ||
deployDir = stagingDeployDir | ||
cliDir = productionCliDir + '-' + gemmaVersion | ||
} else { | ||
deployDir = 'chalmers:' + deployDir | ||
} | ||
if (env.BRANCH_NAME =~ '^(hotfix|release)-.*') { | ||
deployDir += '-staging' | ||
} | ||
if (env.BRANCH_NAME != 'master') { | ||
cliDir += '-' + gemmaVersion | ||
// no deployment should occur | ||
} | ||
} | ||
} | ||
|
@@ -102,7 +113,15 @@ pipeline { | |
} | ||
} | ||
} | ||
stage('Run integration tests and perform deployment in parallel') { | ||
stage('Notify a new release is out') { | ||
when { | ||
branch 'master' | ||
} | ||
steps { | ||
slackSend color: 'good', channel: '#gemma', message: "Gemma ${gemmaVersion} has been released! It will be deployed shortly..." | ||
} | ||
} | ||
stage('Run remaining tests and perform deployment in parallel') { | ||
when { | ||
anyOf { | ||
branch 'master' | ||
|
@@ -112,7 +131,34 @@ pipeline { | |
} | ||
} | ||
parallel { | ||
stage('Run slow unit tests and integration tests') { | ||
stage('Run slow unit tests') { | ||
when { | ||
anyOf { | ||
branch 'hotfix-*' | ||
branch 'release-*' | ||
branch 'development' | ||
} | ||
} | ||
steps { | ||
setBuildStatus "Slow tests", "Slow tests for build #${env.BUILD_NUMBER} have started...", 'PENDING' | ||
sh 'mvn -B test -Dgroups=SlowTest' | ||
} | ||
post { | ||
always { | ||
junit testResults: '**/target/surefire-reports/*.xml' | ||
} | ||
success { | ||
setBuildStatus "Slow tests", "Slow tests for build #${env.BUILD_NUMBER} have passed.", 'SUCCESS' | ||
} | ||
failure { | ||
setBuildStatus "Slow tests", "Slow tests for build #${env.BUILD_NUMBER} failed.", 'ERROR' | ||
} | ||
unstable { | ||
setBuildStatus "Slow tests", "Slow tests for build #${env.BUILD_NUMBER} failed.", 'FAILURE' | ||
} | ||
} | ||
} | ||
stage('Run integration tests') { | ||
when { | ||
anyOf { | ||
branch 'hotfix-*' | ||
|
@@ -121,15 +167,14 @@ pipeline { | |
} | ||
} | ||
steps { | ||
setBuildStatus "Integration tests", "Integration tests #${env.BUILD_NUMBER} have started...", 'PENDING' | ||
setBuildStatus "Integration tests", "Integration tests for build #${env.BUILD_NUMBER} have started...", 'PENDING' | ||
sh 'mvn -B test -Dgroups=SlowTest' | ||
lock('database/' + testdbUrl) { | ||
sh 'mvn -B verify -DskipUnitTests' | ||
} | ||
} | ||
post { | ||
always { | ||
junit testResults: '**/target/surefire-reports/*.xml' | ||
junit testResults: '**/target/failsafe-reports/*.xml' | ||
} | ||
success { | ||
|
@@ -165,8 +210,8 @@ pipeline { | |
} | ||
steps { | ||
sh 'mvn -B site-deploy' | ||
sh "ln -sf ${siteDir}/gemma/gemma-${gemmaVersion} ${dataDir}/gemma-devsite" | ||
sh "ln -sf ${siteDir}/baseCode/baseCode-${baseCodeVersion} ${dataDir}/basecode-site" | ||
sh "ln -sf ${gemmaSiteDir} ${dataDir}/gemma-devsite" | ||
sh "ln -sf ${baseCodeSiteDir} ${dataDir}/basecode-site" | ||
} | ||
} | ||
stage ('Deploy Gemma Web') { | ||
|
@@ -199,6 +244,13 @@ pipeline { | |
} | ||
} | ||
post { | ||
success { | ||
script { | ||
if (env.BRANCH_NAME == "master") { | ||
slackSend color: 'good', message: "Gemma ${gemmaVersion} has been deployed! Enjoy it while it's still warm!" | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idem here. |
||
fixed { | ||
slackSend color: 'good', message: "${env.JOB_NAME} - #${env.BUILD_NUMBER} Back to normal (<${env.BUILD_URL}|Open>)" | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This belong in a different PR.