Skip to content

Commit

Permalink
Add push to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
pfeuffer committed Jan 27, 2023
1 parent 95ce964 commit 30a7416
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ pipeline {
}
}

stage('Push to GitHub') {
when {
branch 'master'
}
steps {
authGit 'cesmarvin', "push -f https://github.com/scm-manager/website HEAD:${env.BRANCH_NAME}"
}
}

stage('Trigger Dependend Builds') {
when {
branch 'master'
Expand Down Expand Up @@ -147,3 +156,12 @@ String computeVersion() {
def commitHashShort = sh(returnStdout: true, script: 'git rev-parse --short HEAD')
return "${new Date().format('yyyyMMddHHmm')}-${commitHashShort}".trim()
}

void authGit(String credentials, String command) {
withCredentials([
usernamePassword(credentialsId: credentials, usernameVariable: 'AUTH_USR', passwordVariable: 'AUTH_PSW')
]) {
sh "git -c credential.helper=\"!f() { echo username='\$AUTH_USR'; echo password='\$AUTH_PSW'; }; f\" ${command}"
}
}

0 comments on commit 30a7416

Please sign in to comment.