- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 SonarQube 服务器和一个 Jenkins 服务器。 Jenkins 服务器安装了以下插件。
pipeline {
/*
* Run everything on an existing agent configured with a label 'windows'.
* TODO : Once we have enough agents, distribute to get fastest feedback!
*/
agent any
/*
agent {
node {
label 'windows'
}
}
*/
/*
* We are getting a lot of values from BitBucket notifier plugin.
*/
parameters {
string(defaultValue: '', description: '', name: 'PULL_REQUEST_URL')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_VERSION')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_AUTHOR_SLUG')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_TO_SSH_CLONE_URL')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_FROM_BRANCH')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_TO_BRANCH')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_TO_REPO_NAME')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_ID')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_TITLE')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_ACTION')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_REVIEWERS_SLUG')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_AUTHOR_EMAIL')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_AUTHOR_DISPLAY_NAME')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_USER_EMAIL_ADDRESS')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_USER_DISPLAY_NAME')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_STATE')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_REVIEWERS_EMAIL')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_REVIEWERS_APPROVED_COUNT')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_FROM_BRANCH')
string(defaultValue: '', description: '', name: 'PULL_REQUEST_TO_REPO_PROJECT_KEY')
}
/* Add timestamps to the console log. Discard old builds.
options {
timestamps()
buildDiscarder(logRotator(numToKeepStr: '20'))
}
*/
/* Stages can be parallel or sequential */
stages {
stage('Source-Code-Management') {
steps {
git(url: 'ssh://mybitbucketserver.com:7999/dev/sitecore.git', branch: '${PULL_REQUEST_FROM_BRANCH}', credentialsId: 'root')
powershell "git merge origin/${PULL_REQUEST_TO_BRANCH}"
}
}
stage('Build and Analyze') {
steps {
script {
// Todo we should be using environment variables or properties for sonar scanner and not have hardcoded values
bat "\"${tool 'nuget-4.3.0'}\" restore src/Nemlig.sln -NoCache"
withSonarQubeEnv('Local') {
bat "\"${tool 'SonarScanner.MSBuild.exe'}\" begin /d:sonar.login=mytoken /k:TEST /n:Website /v: /d:sonar.host.url=${SONAR_URL} /d:sonar.cs.nunit.reportsPaths=${WORKSPACE}\\NUnitResult.xml /d:sonar.cs.opencover.reportsPaths=${WORKSPACE}\\OpenCoverResult.xml"
bat "\"${tool 'MSBuild-v15'}\" src/Nemlig.sln /p:Configuration=debug"
// Note that this shell can retrieve value with CRLF and NUNIT will puke. Must replace with spaces...
def dlls = powershell(returnStdout: true, script: '(ls -Recurse src\\*\\bin\\*.Test.dll | % FullName)')
dlls = dlls.replaceAll('\r\n', ' ')
mycmd = "OpenCover.Console.exe -register:path64 -target:\"nunit3-console.exe\" -returntargetcode -targetargs:\"$dlls --result=NUnitResult.xml\" -output:OpenCoverResult.xml"
powershell (returnStatus: true, script: "$mycmd")
bat "\"${tool 'SonarScanner.MSBuild.exe'}\" end /d:sonar.login=mytoken"
}
}
}
}
stage('SonarQube Quality Gate') {
steps {
script {
timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout
def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}
stage('Deploy Team Environment') {
parallel {
stage('Deploy Site') {
steps {
powershell 'Write-Output "Here we could do a deploy of the site"'
}
}
stage('Deploy Backend') {
steps {
powershell 'Write-Output "Here we could do a deploy of the backend and maybe database changes?"'
}
}
}
}
stage('Smoke') {
parallel {
stage('Chrome') {
steps {
powershell 'Write-Output "Execute Smoke on Chrome"'
}
}
stage('Firefox') {
steps {
powershell 'Write-Output "Execute Smoke on Firefox"'
}
}
stage('Safari') {
steps {
powershell 'Write-Output "Execute Smoke on Safari"'
}
}
}
}
stage('integrate') {
steps {
powershell 'Write-Output "Push merge if all is success!"'
}
}
stage('Store Binary') {
steps {
powershell 'Write-Output "Put the tested binary in Artifactory. Maybe tag it with SHA and Build Number?"'
}
}
}
post {
// Add the publish merge steps...
// Add the notifiy Jira steps
always {
script {
currentBuild.result = currentBuild.result ?: 'SUCCESS'
notifyBitbucket()
}
nunit testResultsPattern: "NUnitResult.xml"
}
}
}
Checking status of SonarQube task 'AWKwODGjKw9CRrvU3S27' on server 'Local'
Error 401 on http://mysonarserver.com:9000/api/ce/task?id=AWKwODGjKw9CRrvU3S27
ANALYSIS SUCCESSFUL, you can browse http://10.100.1.189:9000/dashboard/index/TEST
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://mysonarserver.com:9000/api/ce/task?id=AWKwODGjKw9CRrvU3S27
INFO: Task total time: 3:00.752 s
{
"serverUrl": "http://localhost:9000", "taskId": "AWKwODGjKw9CRrvU3S27", "status": "SUCCESS", "analysedAt":
"2018-04-11T07:41:40+0000", "changedAt": "2018-04-11T07:41:40+0000", "project":
{ "key": "TEST", "name": "Website", "url": "http://localhost:9000/dashboard?id=TEST" }, "branch":
{ "name": "master", "type": "LONG", "isMain": true, "url": "http://localhost:9000/dashboard?id=TEST" },
"qualityGate": {
"name": "Website", "status": "OK", "conditions": [{
"metric": "new_reliability_rating", "operator":
"GREATER_THAN", "value": "3", "status": "OK", "onLeakPeriod":
true, "errorThreshold": "3"
}, {
"metric": "new_duplicated_lines_density", "operator":
"GREATER_THAN", "status": "NO_VALUE", "onLeakPeriod": true,
"errorThreshold": "3"
}, {
"metric": "new_security_rating", "operator": "GREATER_THAN",
"value": "4", "status": "OK", "onLeakPeriod": true,
"errorThreshold": "4"
}, {
"metric": "blocker_violations", "operator": "GREATER_THAN",
"value": "-2", "status": "OK", "onLeakPeriod": true,
"errorThreshold": "35"
}, {
"metric": "new_maintainability_rating", "operator":
"GREATER_THAN", "value": "1", "status": "OK", "onLeakPeriod":
true, "errorThreshold": "1"
}]
}, "properties": {}
}
最佳答案
waitForQualityGate()
step 需要一些凭据才能从 SQ 服务器获取质量门详细信息。凭据应在 Jenkins 全局配置中设置,适用于您的 'Local'
服务器。
但是根据您的管道片段,我看到您正在手动传递 /d:sonar.login=mytoken
到扫描仪。这不受支持。请在全局服务器配置中设置 token 。
关于SonarQube waitForQualityGate() 返回 401,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49769197/
我有一个 SonarQube 服务器和一个 Jenkins 服务器。 Jenkins 服务器安装了以下插件。 质量门插件 Sonar 质量门插件 SonarQubeScanner 我已经使用以下 UR
我的方法 waitForQualityGate() 有问题。我收到错误消息“在步骤中找不到这样的 DSL 方法‘waitForQualityGate’”。另一件奇怪的事情是我必须为 Sonar 扫描仪
Jenkins 2.50 中声明性管道中的以下 SonarQube (6.3) 分析阶段失败,控制台日志中出现此错误:http://pastebin.com/t2ja23vC .进一步来说: Sona
我正在使用 Jenkins 2.89、SonarQube Scanner for Jenkins 2.6.1 和 SonarQube 6.7 配置了一个 webhook 到 Jenkins。 我正在触
我正在运行一个 Jenkins 实例,它有 1 个主服务器/1 个从服务器,连接到一个 Sonarqube 实例。我正在使用管道作业,它工作正常,除了在“WaitForQualityGate”阶段不起
我在 jenkins 管道中使用了 sonarQube。我已经在 jenkins 中安装了所有与 sonarqube 相关的插件。在jenkins配置系统中,我正确配置了sonarqube服务器,je
我最近能够让我的 jenkins 实例连接到 https sonarqube 实例以运行 sonar-scanner withCredentials([[ $class: 'UsernameP
在 Jenkins 中使用 waitForQualityGate() 步骤运行多分支管道作业时,Jenkins 抛出 groovy.lang.ReadOnlyPropertyException: Ca
我是一名优秀的程序员,十分优秀!