-
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.
- Loading branch information
Showing
1 changed file
with
47 additions
and
46 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 |
---|---|---|
|
@@ -200,53 +200,7 @@ parallel( | |
|
||
|
||
|
||
void createNpmrcFile(credentialsId) { | ||
withCredentials([usernamePassword(credentialsId: "${credentialsId}", usernameVariable: 'TARGET_USER', passwordVariable: 'TARGET_PSW')]) { | ||
withEnv(["HOME=${env.WORKSPACE}"]) { | ||
String NPM_TOKEN = """${sh( | ||
returnStdout: true, | ||
script: 'echo -n "${TARGET_USER}:${TARGET_PSW}" | openssl base64' | ||
)}""".trim() | ||
writeFile encoding: 'UTF-8', file: 'app/src/main/ui/.npmrc', text: """ | ||
@cloudogu:registry=https://ecosystem.cloudogu.com/nexus/repository/npm-releases/ | ||
[email protected] | ||
always-auth=true | ||
_auth=${NPM_TOKEN} | ||
""".trim() | ||
} | ||
} | ||
} | ||
|
||
void stageStaticAnalysisSonarQube() { | ||
def scannerHome = tool name: 'sonar-scanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation' | ||
withSonarQubeEnv { | ||
sh "git config 'remote.origin.fetch' '+refs/heads/*:refs/remotes/origin/*'" | ||
gitWithCredentials("fetch --all") | ||
|
||
if (currentBranch == productionReleaseBranch) { | ||
echo "This branch has been detected as the production branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME}" | ||
} else if (currentBranch == developmentBranch) { | ||
echo "This branch has been detected as the development branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME}" | ||
} else if (env.CHANGE_TARGET) { | ||
echo "This branch has been detected as a pull request." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${developmentBranch}" | ||
} else if (currentBranch.startsWith("feature/")) { | ||
echo "This branch has been detected as a feature branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME}" | ||
} else { | ||
echo "This branch has been detected as a miscellaneous branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME} " | ||
} | ||
} | ||
timeout(time: 2, unit: 'MINUTES') { // Needed when there is no webhook for example | ||
def qGate = waitForQualityGate() | ||
if (qGate.status != 'OK') { | ||
unstable("Pipeline unstable due to SonarQube quality gate failure") | ||
} | ||
} | ||
} | ||
}, | ||
"dogu-integration": { | ||
node('vagrant') { | ||
|
@@ -311,6 +265,53 @@ void gitWithCredentials(String command) { | |
) | ||
} | ||
} | ||
void createNpmrcFile(credentialsId) { | ||
withCredentials([usernamePassword(credentialsId: "${credentialsId}", usernameVariable: 'TARGET_USER', passwordVariable: 'TARGET_PSW')]) { | ||
withEnv(["HOME=${env.WORKSPACE}"]) { | ||
String NPM_TOKEN = """${sh( | ||
returnStdout: true, | ||
script: 'echo -n "${TARGET_USER}:${TARGET_PSW}" | openssl base64' | ||
)}""".trim() | ||
writeFile encoding: 'UTF-8', file: 'app/src/main/ui/.npmrc', text: """ | ||
@cloudogu:registry=https://ecosystem.cloudogu.com/nexus/repository/npm-releases/ | ||
[email protected] | ||
always-auth=true | ||
_auth=${NPM_TOKEN} | ||
""".trim() | ||
} | ||
} | ||
} | ||
|
||
void stageStaticAnalysisSonarQube() { | ||
def scannerHome = tool name: 'sonar-scanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation' | ||
withSonarQubeEnv { | ||
sh "git config 'remote.origin.fetch' '+refs/heads/*:refs/remotes/origin/*'" | ||
gitWithCredentials("fetch --all") | ||
|
||
if (currentBranch == productionReleaseBranch) { | ||
echo "This branch has been detected as the production branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME}" | ||
} else if (currentBranch == developmentBranch) { | ||
echo "This branch has been detected as the development branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME}" | ||
} else if (env.CHANGE_TARGET) { | ||
echo "This branch has been detected as a pull request." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${developmentBranch}" | ||
} else if (currentBranch.startsWith("feature/")) { | ||
echo "This branch has been detected as a feature branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME}" | ||
} else { | ||
echo "This branch has been detected as a miscellaneous branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME} " | ||
} | ||
} | ||
timeout(time: 2, unit: 'MINUTES') { // Needed when there is no webhook for example | ||
def qGate = waitForQualityGate() | ||
if (qGate.status != 'OK') { | ||
unstable("Pipeline unstable due to SonarQube quality gate failure") | ||
} | ||
} | ||
} | ||
|
||
|
||
|