Add pipeline.groovy
This commit is contained in:
parent
6ab8be4237
commit
37bb917fde
83
pipeline.groovy
Normal file
83
pipeline.groovy
Normal file
@ -0,0 +1,83 @@
|
||||
pipeline {
|
||||
agent any
|
||||
environment {
|
||||
CLONE_STAGE_STATUS = "FAIL"
|
||||
PYLINT_STAGE_STATUS = "FAIL"
|
||||
GENERATE_BUILD_INFORMATION_STAGE_STATUS = "FAIL"
|
||||
BUILD_STAGE_STATUS = "FAIL"
|
||||
UNIT_TEST_STAGE_STATUS = "FAIL"
|
||||
PYPI_STAGE_STATUS = "FAIL"
|
||||
AUTO_DOC_STAGE_STATUS = "FAIL"
|
||||
MAINTAINERS = "anhhoang.nguyen@concordia.ca"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Clone') {
|
||||
steps {
|
||||
script {
|
||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||
echo 'Start branch development pipeline'
|
||||
dir('webhook-test') {
|
||||
git branch: 'main', changelog: false, credentialsId: 'Terence', poll: false, url: 'https://nextgenerations-cities.encs.concordia.ca/gitea/a_nguyen/webhook-test.git'
|
||||
}
|
||||
CLONE_STAGE_STATUS = "SUCCESS"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Webhook Handler') {
|
||||
steps {
|
||||
script {
|
||||
// Get the raw JSON content from the REQUEST_CONTENT environment variable
|
||||
// def rawPayload = env.REQUEST_CONTENT
|
||||
|
||||
// Parse the JSON content using jsonSlurper
|
||||
def jsonSlurper = new groovy.json.JsonSlurper()
|
||||
def jsonPayload = jsonSlurper.parseText(payload)
|
||||
|
||||
echo jsonPayload.sender.login + " " + jsonPayload.sender.email + " " + jsonPayload.sender.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Get/Set Build Information') {
|
||||
steps {
|
||||
sh 'rm -r webhook-test/.jenkins || echo "Creating runtime .jenkins folder. Will be removed in cleanup stage." && mkdir -p webhook-test/.jenkins'
|
||||
|
||||
sh 'cd webhook-test && git log -1 --pretty=format:\'%an\' > .jenkins/git_author && git log -1 --pretty=format:\'%ae\' > .jenkins/git_author_email && git log -1 --pretty=format:\'%h\' > .jenkins/git_hash'
|
||||
|
||||
script {
|
||||
GENERATE_BUILD_INFORMATION_STAGE_STATUS="SUCCESS"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Cleanup') {
|
||||
steps {
|
||||
script {
|
||||
git_author = readFile('webhook-test/.jenkins/git_author').trim()
|
||||
git_author_email = readFile('webhook-test/.jenkins/git_author_email').trim()
|
||||
git_hash = readFile('webhook-test/.jenkins/git_hash').trim()
|
||||
}
|
||||
mail to: "13dd15fb.liveconcordia.onmicrosoft.com@ca.teams.ms",
|
||||
subject: "${env.BUILD_TAG} Pipeline Results",
|
||||
body: """
|
||||
Results of Hub/release Pipeline ${env.BUILD_TAG}
|
||||
|
||||
Build triggered by: "${jsonPayload.sender.name} - ${jsonPayload.sender.login}"
|
||||
Commit hash: "${jsonPayload.after}"
|
||||
See changes: "${jsonPayload.compare_url}"
|
||||
Email: "${jsonPayload.sender.email}"
|
||||
|
||||
Clone Stage: ${CLONE_STAGE_STATUS}
|
||||
Generate Build Information Stage: ${GENERATE_BUILD_INFORMATION_STAGE_STATUS}
|
||||
Build Stage : ${BUILD_STAGE_STATUS}
|
||||
Unit Test Stage: ${UNIT_TEST_STAGE_STATUS}
|
||||
|
||||
To access the pipeline run logs, please go here: http://nextgenerations-cities.encs.concordia.ca:8080/job/Hub/job/release/
|
||||
"""
|
||||
sh 'rm -rf webhook-test/.jenkins'
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -29,8 +29,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_user_age() {
|
||||
let user = User::new("Test User", 2000);
|
||||
let user = User::new("Test User", 1999);
|
||||
let age = user.age();
|
||||
assert_eq!(age, 23); // Adjust the expected age based on the current year
|
||||
assert_eq!(age, 24); // Adjust the expected age based on the current year
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user