Skip to content

Commit

Permalink
Changed the credential id in Jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
alecszaharia committed Feb 28, 2019
1 parent 6c38321 commit ba53f5a
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
def now = new Date()
def currentDate = now.format("yyyy-MM-dd", TimeZone.getTimeZone('UTC'))
def changeLogs = params.changelog.replaceAll("\n","\\\\n").replaceAll("/",'\\\\/')
def zipFileName = "Build-"+params.buildVersion+".zip"
def zipFileName = "Build-"+params.buildVersion+"-RC.zip"
env.BUILD_ZIP_PATH = params.brizySvnPath+"/"+zipFileName

def notifySlack(String buildResult = 'STARTED', String zipPath = '') {
if(params.gitMerge) {
zipFileName = "Build-"+params.buildVersion+".zip"
}


def notifySlack(String buildResult = 'STARTED', String zipPath = '') {

def buildInfo = "\nBranch: "+params.releaseBranch+"\nPlugin version: "+params.buildVersion+"\nEditor version: "+params.editorVersion+"\nChangelog\n"+params.changelog;

if ( buildResult == "SUCCESS" ) {
slackSend color: "good", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was successful."+buildInfo
withCredentials([string(credentialsId: 'slack', variable: 'SECRET')]) {

if ( buildResult == "SUCCESS" ) {
slackSend channel: '#jenkins', color: "good", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was successful."+buildInfo

withCredentials([string(credentialsId: 'Slack Oauth Token', variable: 'SECRET')]) {
sh '''
set +x
curl -F file=@$BUILD_ZIP_PATH -F channels=#jenkins -F token="$SECRET" https://slack.com/api/files.upload
set +x
curl -F file=@$BUILD_ZIP_PATH -F channels=#jenkins -F token="$SECRET" https://slack.com/api/files.upload
'''
}

}
else if( buildResult == "FAILURE" ) {
slackSend color: "danger", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was failed."+buildInfo
}
else if( buildResult == "UNSTABLE" ) {
slackSend color: "warning", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was unstable."+buildInfo
}
else {
slackSend color: "danger", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} its result was unclear."+buildInfo
}
}
else if( buildResult == "FAILURE" ) {
slackSend channel: '#jenkins', color: "danger", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was failed."+buildInfo
}
else if( buildResult == "UNSTABLE" ) {
slackSend channel: '#jenkins', color: "warning", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was unstable."+buildInfo
}
else {
slackSend channel: '#jenkins', color: "danger", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} its result was unclear."+buildInfo
}
}
}

def folderExist(path){
Expand All @@ -47,7 +51,7 @@ pipeline {
}

git url: "git@github.com:/ThemeFuse/Brizy",
credentialsId: '7ca32202-12d1-4189-9ff3-093095f8ffc3',
credentialsId: 'Git',
branch: params.releaseBranch

sh 'git config user.name "Alex Zaharia"'
Expand All @@ -70,7 +74,6 @@ pipeline {
}

stage('Prepare SVN') {

steps {
sh 'cd ' + params.brizySvnPath + ' && svn cleanup && svn revert . -R && svn up'
sh 'cd ' + params.brizySvnPath + ' && rm -rf trunk/*'
Expand Down Expand Up @@ -98,22 +101,22 @@ pipeline {
}

stage('Git Merge') {
when {
expression { return params.gitMerge }
}
steps {
sh 'git commit -a -m "Build '+params.buildVersion+'"'
sh 'git checkout -t origin/master'
sh 'git merge --no-ff -m "Merge ['+params.releaseBranch+'] in master" '+params.releaseBranch
sh 'git tag '+params.buildVersion
sh 'git checkout -t origin/develop'
sh 'git merge --no-ff -m "Merge ['+params.releaseBranch+'] in develop" '+params.releaseBranch

sshagent (credentials: ['7ca32202-12d1-4189-9ff3-093095f8ffc3']) {
sh 'git push origin master && git push origin develop && git push origin --tags && git push origin '+params.releaseBranch
}
}
when {
expression { return params.gitMerge }
}
steps {
sh 'git commit -a -m "Build '+params.buildVersion+'"'
sh 'git checkout -t origin/master'
sh 'git merge --no-ff -m "Merge ['+params.releaseBranch+'] in master" '+params.releaseBranch
sh 'git tag '+params.buildVersion
sh 'git checkout -t origin/develop'
sh 'git merge --no-ff -m "Merge ['+params.releaseBranch+'] in develop" '+params.releaseBranch

sshagent (credentials: ['Git']) {
sh 'git push origin master && git push origin develop && git push origin --tags && git push origin '+params.releaseBranch
}
}
}

stage('Publish') {
when {
Expand All @@ -124,7 +127,6 @@ pipeline {
sh 'cd ' + params.brizySvnPath + ' && svn commit --non-interactive --trust-server-cert --username themefusecom --password \''+params.svnPassword+'\' -m "Version '+params.buildVersion+'"'
}
}

}

post {
Expand Down

0 comments on commit ba53f5a

Please sign in to comment.