-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in feature/MTM-35567/migrate_jenkinsfile (pull request #16)
refactor
- Loading branch information
Showing
6 changed files
with
216 additions
and
19 deletions.
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 |
---|---|---|
@@ -0,0 +1,137 @@ | ||
pipeline { | ||
agent { | ||
kubernetes { | ||
label 'mono3' | ||
inheritFrom 'mono3' | ||
defaultContainer 'default' | ||
} | ||
} | ||
triggers{ | ||
bitbucketPush() | ||
} | ||
options{ | ||
buildDiscarder(logRotator(numToKeepStr: '10')) | ||
timeout(time: 1, unit: 'HOURS') | ||
disableConcurrentBuilds() | ||
} | ||
parameters { | ||
booleanParam(defaultValue: true, description: '', name: 'DIAGNOSTIC_FLAG') | ||
booleanParam(defaultValue: false, description: '', name: 'CAN_RELEASE') | ||
} | ||
environment { | ||
CI = 'true' | ||
} | ||
stages { | ||
stage('Build') { | ||
|
||
when { | ||
anyOf{ | ||
branch 'develop' | ||
branch 'feature/**' | ||
} | ||
} | ||
steps { | ||
|
||
script { | ||
if ("${params.CAN_RELEASE}" == "true" && env.BRANCH_NAME == "develop") { | ||
echo "CAN_RELEASE: ${params.CAN_RELEASE}" | ||
|
||
sshagent (['jenkins-master-key']) { | ||
sh '''#!/bin/bash | ||
whoami | ||
chmod +x ./MicroservicesSDK/build.sh | ||
cd MicroservicesSDK | ||
pwd | ||
./build.sh --script build-release.cake | ||
''' | ||
} | ||
} | ||
else{ | ||
if ("${params.DIAGNOSTIC_FLAG}" == "true") { | ||
echo "diagnostic flag: ${params.DIAGNOSTIC_FLAG}" | ||
sh 'cd MicroservicesSDK && chmod +x ./build.sh && pwd && ./build.sh -target=Test -verbosity=diagnostic' | ||
}else | ||
{ | ||
echo "diagnostic flag: ${params.DIAGNOSTIC_FLAG}" | ||
sh 'cd MicroservicesSDK && chmod +x ./build.sh && pwd && ./build.sh -target=Test' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
stage('Deliver for development') { | ||
when { | ||
branch 'development' | ||
} | ||
steps { | ||
sh 'echo DevelopmentBranch' | ||
} | ||
} | ||
stage('Release') { | ||
when { | ||
branch "release/*" | ||
} | ||
steps { | ||
script { | ||
if ("${params.DIAGNOSTIC_FLAG}" == "true" && ("${params.CAN_RELEASE}" == "true")) { | ||
sh 'echo Release Branch' | ||
echo "diagnostic flag: ${params.DIAGNOSTIC_FLAG}" | ||
|
||
echo "Release Branch" | ||
|
||
sshagent (['jenkins-master-key']) { | ||
sh '''#!/bin/bash | ||
whoami | ||
chmod +x ./MicroservicesSDK/build.sh | ||
cd MicroservicesSDK | ||
pwd | ||
./build.sh --script build-release.cake -verbosity=diagnostic | ||
''' | ||
} | ||
|
||
}else if ("${params.CAN_RELEASE}" == "true") | ||
{ | ||
echo "Release Branch" | ||
|
||
sshagent (['jenkins-master-key']) { | ||
sh '''#!/bin/bash | ||
whoami | ||
chmod +x ./MicroservicesSDK/build.sh | ||
cd MicroservicesSDK | ||
pwd | ||
./build.sh --script build-release.cake | ||
''' | ||
} | ||
} else { | ||
sh 'echo Release Branch' | ||
echo "CAN_RELEASE: ${params.CAN_RELEASE}" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
post { | ||
success{ | ||
|
||
withCredentials([usernamePassword(credentialsId: 'bitbucket-m2m', passwordVariable: 'BITBUCKET_PASSWORD', usernameVariable: 'BITBUCKET_USER')]) { | ||
sh "chmod +x .jenkins/scripts/status.sh && .jenkins/scripts/status.sh 'SUCCESSFUL' ${JOB_NAME} ${BUILD_TAG} " | ||
} | ||
} | ||
failure { | ||
script { | ||
if (env.BRANCH_NAME ==~ '(develop|release/.*)') { | ||
chat 'AAAAvnc5o90' | ||
} | ||
} | ||
|
||
withCredentials([usernamePassword(credentialsId: 'bitbucket-m2m', passwordVariable: 'BITBUCKET_PASSWORD', usernameVariable: 'BITBUCKET_USER')]) { | ||
sh "chmod +x .jenkins/scripts/status.sh && .jenkins/scripts/status.sh 'FAILED' ${JOB_NAME} ${BUILD_TAG} " | ||
} | ||
} | ||
cleanup { | ||
echo 'One way or another, I have finished.' | ||
deleteDir() /* clean up our workspace */ | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
pipeline { | ||
agent{ | ||
label 'mono3' | ||
} | ||
options { | ||
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5')) | ||
disableConcurrentBuilds() | ||
} | ||
stages { | ||
stage('Checkout') { | ||
steps { | ||
container('default') { | ||
checkout([ | ||
$class: 'GitSCM', branches: [[name: 'feature/MTM-35567/migrate_jenkinsfile']], | ||
extensions: [[$class: 'CleanCheckout']], | ||
userRemoteConfigs: [[url: 'git@bitbucket.org:m2m/cumulocity-clients-cs.git',credentialsId:'jenkins-master']] ]) | ||
} | ||
} | ||
stage('Build') { | ||
steps { | ||
container('dotnet-sdk-3-1') { | ||
sshagent(['jenkins-master']){ | ||
sh 'cd DeviceSDK/MQTT/ && chmod +x ./build.sh && pwd && ./build.sh -target=Test' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
echo 'The following command terminates the "npm start" process using its PID' | ||
echo '(written to ".pidfile"), all of which were conducted when either' | ||
set -x | ||
kill $(cat .pidfile) |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
function update-status { | ||
commitId=${GIT_REVISION} | ||
status=${1} | ||
name=${2} | ||
key=$( echo $3 | rev | cut -c -40 | rev ) | ||
echo "Sending build status update for commitId: ${commitId}, status: ${status}, name: ${name} , key: ${key}" | ||
echo $(curl -s --user ${BITBUCKET_USER}:${BITBUCKET_PASSWORD} -H "Content-Type: application/json" -X POST https://api.bitbucket.org/2.0/repositories/m2m/cumulocity-clients-cs/commit/${commitId}/statuses/build --data "{\"state\":\"${status}\", \"name\": \"${name}\", \"key\": \"${key}\", \"url\": \"http://localhost:8081/job/Cumulocity-CsSDK/job/${BRANCH_NAME}/${BUILD_ID}/\", \"description\": \"\" }") | ||
} | ||
|
||
update-status $1 $2 $3 |
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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
if [ -z "$TPP_FETCHER_URL" ]; then TPP_FETCHER_URL="http://172.30.0.129:8083"; fi | ||
|
||
|
||
if [[ -e Tpp.toml ]] ; then | ||
curl -sS -o tpp-scanner ${TPP_FETCHER_URL}/tpp-scanner \ | ||
&& chmod +x tpp-scanner \ | ||
&& ./tpp-scanner -tpp-fetcher-url ${TPP_FETCHER_URL} \ | ||
&& rm tpp-scanner | ||
exit 0 | ||
fi | ||
|