We are archiving a lot of html reports in a Jenkins pipeline (scripted Pipeline). These are accessible through a link "Last Successful Artifacts" on the job page as usual. But we would like to create an additional custom link that that points to one of these reports (that is being generated whether the build is successful or not).
I found the DocLink plugin, but it's not listed on the pipeline compatibility list and I'm not able to figure out how this eventually could be used in a pipeline.
The HTML Publisher Plugin is another one I was looking at. But it’s not suited for our use case, since it requires us to gather all reports and publish them again. It also puts all the content in an iframe, but all we need is link to one of the already archived html reports.
Here is a example to add summary links to a build
manager.createSummary("document.png").appendText("<a href='"+ pom.url + "'>View Maven Site</a>", false)
As that method accepts HTML and can be used for XSS you need to approve them.
https://jenkins.io/doc/book/managing/script-approval/
for more examples look here: https://wiki.jenkins.io/display/JENKINS/Groovy+Postbuild+Plugin
For pipeline the Badge plugin was extracted from the Groovy Postbuild plugin and if can create the summary using something like:
createSummary icon:'package.png', text: "<a href='$pom.url'>View Maven Site</a>"
Related
We run our protractor regression tests in gitlab CI and we have jasmine HTML reports. Right now it is only the QA team that monitors and checks failure if any.
But we would like to make it more visible. The devs have also asked us if we can make it visible in a single place instead of having to go to gitlab job and browse for artifacts.Also would it be possible to have an overview of pass/fail tests over time.
I'm not sure how and where to start. Any pointers would be appreciated.
You're looking for the expose_as keyword for artifacts. The full docs are here: https://docs.gitlab.com/ee/ci/yaml/#artifactsexpose_as.
If you use expose_as with your artifacts, Gitlab CI will link them to any application Merge Request with the name you give in this field.
For example (from the docs):
test:
script: ["echo 'test' > file.txt"]
artifacts:
expose_as: 'artifact 1'
paths: ['file.txt']
In this example, a Merge Request for this pipeline will have a link called "artifact 1" that opens the file "file.txt".
This also works for directories, but if there's more than one file it will open in the job's artifacts browser (like you currently do).
There are some caveats, like:
If you use a variable in the artifacts path field, expose_as won't work
Max of 10 artifacts can be exposed
Glob patters won't work
If Gitlab Pages is enabled, some file extensions will be automatically rendered using Pages (html, xml, txt, etc.).
I am trying to find a portable way to produce code annotations for GitHub in a way that would avoid a vendor-lockin.
Mainly I want to dump annotations inside a file (yaml, json,...) during build process and have a task at the end that does transform this file into github annotations.
The main goal here is to avoid hardcoding support for github-annotation into the tools that produce them, so other CI/CD systems could also consume the annotation-reports and display them in their UI.
linters -> annotations.report -> github-upload
Tools like flake8 are able to produce output in parsable format file:line:column: message, but I need to know if there is any attempt to standardize annotations so we can collect and combine them from multiple tools and feed them to the CI/CD engine.
Today I googled up what the heck those "Github Action Annotations" are all, and this was among the hits:
https://github.com/marketplace/actions/annotations-action
GitHub action for creating annotations from JSON file
As of now that page also contains:
This repository uses npm packages from #attest scope on github; we are working hard to open source these packages.
Annotations Action is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.
I didn't try it, again, just a random google hit.
I am currently using https://github.com/yuzutech/annotations-action
Sample action code:
- name: Annotate
uses: yuzutech/annotations-action#v0.3.0
with:
repo-token: ${{secrets.GITHUB_TOKEN}}
input: ./annotations.json
title: 'Findings'
ignore-missing-file: true
It does its job well but with one minor defect. If you have a findings on a commit/PR you get to see the finding with a beautiful annotation right where you need it. If you re-push changes, even if the finding persists, the annotation is not displayed on later commits. I have opened an issue but I have not yet received an answer.
The annotations-action mentioned above has not been updated and it does not work with me at all (deprecated calls).
I haven't found anything else that worked exactly as I wanted it to.
Update: I found that you can use reviewdog to annotate based on findings. I also created a GitHub action that can be used for Static Code Analysis here https://github.com/tsigouris007/action-semgrep-reviewdog. You can visit the entrypoint.sh file and check how I piped the custom output to reviewdog utilizing jq.
I have a shell script that logs on to the given server, finds all the wars running on the same and prints their name and versions to the console.
I need to take this output and display it on a page in confluence.
I went through this plugin for Jenkins and can connect and print static stuff on the page I provide.
The output that my script creates is dynamic, how do I, say store it in a variable and use it in the: Post-build Actions -> Publish to confluence -> Wiki Markup Replacements.
I have googled around and played with Jenkins to get these results, to no avail. I have seen '/env-vars.html' page, but none of these are of use to me, for my data is dynamic.
I referred this to accomplish this task.
We're going to trigger hudson builds from powershell using curl and the build url:
http://hudson:port/job/build?parameters...
now I'm wondering if we can somehow pass a parameter that will add to the "triggered by" description for the builds started by our scripts?
I don't know how to edit the "triggered by" info on the build summary page without writing your own Hudson plugin. However, I like to add my own sections and badges to the build summary page with the Groovy Postbuild Plugin. In your case, you could use curl to pass an extra parameter string when starting your Hudson job. Then, you could have the Groovy Postbuild Plugin read that parameter and create a new icon + text string on your job's build summary page. That info could be the custom "triggered by" description that you'd like.
I've been evaluating Hudson, with an eye to convert to it from CC.NET. In CC.NET, I've gotten my emails to include test statistics, such as # of tests run, how many failed, etc. It even shows in red "this project has no tests" which is a great motivator, right?
Is there any way to accomplish this in Hudson?
I've tried the email-ext plugin, because I'm told that it can get test output and other great stuff into the email, but I just can't figure out "how."
It looks like I need to put a token in for "content" but I dont see any token available that looks like "test results" to me :) Or any that would parse some xml that I provide a path to, or such.
Has anyone done this and can help?
Thanks!
From the Email-ext plugin wiki page:
To see a list of all available email tokens and what they display, you can click the "?" (question mark) at the top of the email-ext section on the project configuration screen.
I can't check if it's listed in the online help right now but I think you're looking for the $FAILED_TESTS token.
If you need more guidance, check this blog post: Continuous Integration with Hudson, ColdFusion, and MXUnit: Advanced Notification Control. There are some screenshots that might help.
See this question - Having Latest Tests Results info in the notified email with Hudson . It seems like the only answer is to hack in your own solution, until Email-ext is improved.