groovy scripts
This commit is contained in:
parent
9bccd1f0a1
commit
9cc5f2734b
5
groovy/deploy.groovy
Normal file
5
groovy/deploy.groovy
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
def deploy(String versionName, String staticFolderName) {
|
||||||
|
sshPublisher(publishers: [sshPublisherDesc(configName: 'bro-js-static', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: staticFolderName, remoteDirectorySDF: false, removePrefix: '', sourceFiles: "${versionName}/**")], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: true)])
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
12
groovy/tag.groovy
Normal file
12
groovy/tag.groovy
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
String tag = ''
|
||||||
|
|
||||||
|
def calcTag() {
|
||||||
|
tag = sh(returnStdout: true, script: "git tag --contains").trim()
|
||||||
|
return tag
|
||||||
|
}
|
||||||
|
|
||||||
|
def getTagNoV() {
|
||||||
|
return tag.substring(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
64
predeploy/Jenkinsfile
vendored
64
predeploy/Jenkinsfile
vendored
@ -1,31 +1,71 @@
|
|||||||
|
// stage ('predeploy') {
|
||||||
|
// echo 'checking tag'
|
||||||
|
// script {
|
||||||
|
// def tag = sh(returnStdout: true, script: "git tag --contains").trim()
|
||||||
|
// def branchName = sh(returnStdout: true, script: "git rev-parse --abbrev-ref HEAD").trim()
|
||||||
|
|
||||||
|
// if (tag) {
|
||||||
|
// echo 'found tag ' + tag
|
||||||
|
// addBadge(
|
||||||
|
// icon: 'completed.gif',
|
||||||
|
// text: "Release ${tag}")
|
||||||
|
// def tagNoV = tag.substring(1)
|
||||||
|
// sh "cd ${TARGET_FOLDER}; echo '${tagNoV}' > ${DEPLOY_VERSION_VAR}";
|
||||||
|
// // sh "cd ${TARGET_FOLDER} ; echo 'mkdir ${tagNoV}; mv ./${branchName}/* ./${tagNoV}; rm -r -d ./${branchName}; rm ${DEPLOY_VERSION_VAR}' > ${DEPLOY_VERSION_VAR}"
|
||||||
|
// } else {
|
||||||
|
// echo 'tag not found'
|
||||||
|
// addBadge(
|
||||||
|
// icon: 'info.gif',
|
||||||
|
// text: "Сборка в master")
|
||||||
|
// sh "cd ${TARGET_FOLDER}; echo '${branchName}' > ${DEPLOY_VERSION_VAR}"
|
||||||
|
// // sh "cd ${TARGET_FOLDER} ; echo 'rm ${DEPLOY_VERSION_VAR}' > ${DEPLOY_VERSION_VAR}"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// stage ('archiving') {
|
||||||
|
// // Archive the build output artifacts.
|
||||||
|
// script {
|
||||||
|
// archiveArtifacts artifacts: "${TARGET_FOLDER}/*/**"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
def tagModule = load "${JEN_FILES_TMP_NAME}/groovy/tag.groovy"
|
||||||
|
|
||||||
stage ('predeploy') {
|
stage ('predeploy') {
|
||||||
echo 'checking tag'
|
echo 'checking tag'
|
||||||
script {
|
script {
|
||||||
def tag = sh(returnStdout: true, script: "git tag --contains").trim()
|
tag = tagModule.calcTag()
|
||||||
|
echo "tag is -> ${tag}"
|
||||||
|
println "tagNoV is -> ${tagModule.getTagNoV()}"
|
||||||
def branchName = sh(returnStdout: true, script: "git rev-parse --abbrev-ref HEAD").trim()
|
def branchName = sh(returnStdout: true, script: "git rev-parse --abbrev-ref HEAD").trim()
|
||||||
|
|
||||||
if (tag) {
|
if (tag) {
|
||||||
echo 'found tag ' + tag
|
println "found tag ${tag}"
|
||||||
addBadge(
|
addBadge(
|
||||||
icon: 'completed.gif',
|
icon: 'completed.gif',
|
||||||
text: "Release ${tag}")
|
text: "Release ${tag}")
|
||||||
def tagNoV = tag.substring(1)
|
def tagNoV = tagModule.getTagNoV()
|
||||||
sh "cd ${TARGET_FOLDER}; echo '${tagNoV}' > ${DEPLOY_VERSION_VAR}";
|
sh "mkdir ${tagNoV}"
|
||||||
// sh "cd ${TARGET_FOLDER} ; echo 'mkdir ${tagNoV}; mv ./${branchName}/* ./${tagNoV}; rm -r -d ./${branchName}; rm ${DEPLOY_VERSION_VAR}' > ${DEPLOY_VERSION_VAR}"
|
sh "mv ${TARGET_FOLDER}/* ${tagNoV}"
|
||||||
|
archiveArtifacts artifacts: "${tagNoV}/*/**"
|
||||||
} else {
|
} else {
|
||||||
echo 'tag not found'
|
echo 'tag not found'
|
||||||
addBadge(
|
addBadge(
|
||||||
icon: 'info.gif',
|
icon: 'info.gif',
|
||||||
text: "Сборка в master")
|
text: "Сборка в master")
|
||||||
sh "cd ${TARGET_FOLDER}; echo '${branchName}' > ${DEPLOY_VERSION_VAR}"
|
// sh "cd ${TARGET_FOLDER}; echo '${branchName}' > ${DEPLOY_VERSION_VAR}"
|
||||||
|
sh "mkdir ${branchName}"
|
||||||
|
sh "mv ${TARGET_FOLDER}/* ${branchName}"
|
||||||
// sh "cd ${TARGET_FOLDER} ; echo 'rm ${DEPLOY_VERSION_VAR}' > ${DEPLOY_VERSION_VAR}"
|
// sh "cd ${TARGET_FOLDER} ; echo 'rm ${DEPLOY_VERSION_VAR}' > ${DEPLOY_VERSION_VAR}"
|
||||||
|
archiveArtifacts artifacts: "${TARGET_FOLDER}/*/**"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage ('archiving') {
|
// stage ('archiving') {
|
||||||
// Archive the build output artifacts.
|
// // Archive the build output artifacts.
|
||||||
script {
|
// script {
|
||||||
archiveArtifacts artifacts: "${TARGET_FOLDER}/*/**"
|
// archiveArtifacts artifacts: "${TARGET_FOLDER}/*/**"
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
Loading…
Reference in New Issue
Block a user