Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lastCompletedBuild for [Jenkins] badges and better discoverability #3460

Merged
merged 7 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/jenkins/jenkins-build.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = class JenkinsBuild extends JenkinsBase {

async handle({ protocol, host, job }, { disableStrictSSL }) {
const json = await this.fetch({
url: buildUrl({ protocol, host, job, lastBuild: false }),
url: buildUrl({ protocol, host, job, lastCompletedBuild: false }),
schema,
qs: buildTreeParamQueryString('color'),
disableStrictSSL,
Expand Down
4 changes: 2 additions & 2 deletions services/jenkins/jenkins-build.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const isJenkinsBuildStatus = Joi.alternatives(
)

t.create('build job not found')
.get('/https/updates.jenkins-ci.org/job/does-not-exist.json')
.get('/https/ci.eclipse.org/jgit/job/does-not-exist.json')
.expectBadge({ label: 'build', message: 'instance or job not found' })

t.create('build found (view)')
Expand All @@ -22,7 +22,7 @@ t.create('build found (view)')
.expectBadge({ label: 'build', message: isJenkinsBuildStatus })

t.create('build found (job)')
.get('/https/jenkins.ubuntu.com/server/curtin-vmtest-daily-x.json')
.get('/https/ci.eclipse.org/jgit/job/jgit.json')
.expectBadge({ label: 'build', message: isJenkinsBuildStatus })

const user = 'admin'
Expand Down
10 changes: 8 additions & 2 deletions services/jenkins/jenkins-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ const queryParamSchema = Joi.object({
disableStrictSSL: Joi.equal(''),
}).required()

const buildUrl = ({ protocol, host, job, lastBuild = true, plugin }) => {
const buildUrl = ({
protocol,
host,
job,
lastCompletedBuild = true,
plugin,
}) => {
const jobPrefix = job.indexOf('/') > -1 ? '' : 'job/'
return `${protocol}://${host}/${jobPrefix}${job}/${
lastBuild ? 'lastBuild/' : ''
lastCompletedBuild ? 'lastCompletedBuild/' : ''
}${plugin ? `${plugin}/` : ''}api/json`
}

Expand Down
1 change: 1 addition & 0 deletions services/jenkins/jenkins-coverage.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module.exports = class JenkinsCoverage extends JenkinsBase {
host: 'jenkins.sqlalchemy.org',
job: 'job/alembic_coverage',
},
keywords: ['jacoco', 'cobertura'],
staticPreview: this.render({ coverage: 95 }),
},
]
Expand Down
6 changes: 2 additions & 4 deletions services/jenkins/jenkins-coverage.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ const t = (module.exports = require('../tester').createServiceTester())

t.create('jacoco: job found')
.get('/jacoco/https/wso2.org/jenkins/view/All%20Builds/job/archetypes.json')
.timeout(10000)
.expectBadge({ label: 'coverage', message: isIntegerPercentage })

t.create('jacoco: job not found')
.get('/jacoco/https/updates.jenkins-ci.org/job/does-not-exist.json')
.get('/jacoco/https/wso2.org/jenkins/job/does-not-exist.json')
.expectBadge({ label: 'coverage', message: 'job or coverage not found' })

t.create('cobertura: job not found')
.get('/cobertura/https/updates.jenkins-ci.org/job/does-not-exist.json')
.get('/cobertura/https/jenkins.sqlalchemy.org/job/does-not-exist.json')
.expectBadge({ label: 'coverage', message: 'job or coverage not found' })

t.create('cobertura: job found')
.get('/cobertura/https/jenkins.sqlalchemy.org/alembic_coverage.json')
.timeout(10000)
.expectBadge({ label: 'coverage', message: isIntegerPercentage })
2 changes: 1 addition & 1 deletion services/jenkins/jenkins-tests.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const {
//
// Sample data set for the `actions` array:
// "actions":[{"_class":"hudson.model.ParametersAction"},{"_class":"hudson.model.CauseAction"},{"_class":"hudson.tasks.junit.TestResultAction","failCount":15,"skipCount":0,"totalCount":753},{},{}]
// https://jenkins.qa.ubuntu.com/view/Trusty/view/Smoke%20Testing/job/trusty-touch-flo-smoke-daily/lastBuild/api/json?tree=actions[failCount,skipCount,totalCount]
// https://jenkins.qa.ubuntu.com/view/Trusty/view/Smoke%20Testing/job/trusty-touch-flo-smoke-daily/lastCompletedBuild/api/json?tree=actions[failCount,skipCount,totalCount]
const schema = Joi.object({
actions: Joi.array()
.items(
Expand Down
4 changes: 2 additions & 2 deletions services/jenkins/jenkins-tests.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ t.create('Test status with compact message and custom labels')
})

t.create('Test status on job with no tests')
.get('/https/jenkins.ubuntu.com/server/job/curtin-vmtest-daily-x.json')
.get('/https/ci.eclipse.org/openj9/job/Build-Doc-Push_to_ghpages.json')
.expectBadge({ label: 'tests', message: 'no tests found' })

t.create('Test status on non-existent job')
.get('/https/updates.jenkins-ci.org/job/does-not-exist.json')
.get('/https/ci.eclipse.org/openj9/job/does-not-exist.json')
.expectBadge({ label: 'tests', message: 'instance or job not found' })