I have a Multibranch Pipeline in Jenkins.
My goal is to change the Timestamps of the Builds in the History.
I was able to change the DisplayName (#13 to 'test') as shown in the picture below, but not the timestamp. Is this possible, and if so, how?
After googling for some time I found one wonderful plugin.
https://plugins.jenkins.io/groovy-postbuild/
Groovy Post Build.
This plugin can help you to add custom text, plugin-predefined Icons In Build History side pane after build Timestamp. Like
And this plugin has some other icons also and we can give on hover to those icons.
It's really fun to implement cool stuff there. This plugin has very good documentation and well-defined Examples.
Please have a look, This will resolve your problem.
PS: you need to write some groovy script 😋
[update]
Install plugin:
Jenkins > configure > manage plugin > Avaialble > search for Groovy PostBuild > Install and restart Jenkins
How to use:
Start Configure your project. If the project is FreeStyle then go to post build tab in the configuration page. Like this:
A textArea will open now add your Script as described in Examples.
Now Apply and save. Run the build and tadaaaa.. your message is in build history pane.
I think this could help you to setup and run script
Related
I have installed Jenkins, create a project and configure it.
I run into a problem, Jenkins do everithing great except documentation generating.
Could anyone point me where I have done mistake, and how fix it?
Thank you.
------------------------ New information ----------
Console output:
I have renamed doc to javadoc directory, but it isn't help.
Here is screenshot of javadoc directory contents in console, it is clear that Jenkins plugin didn't generate documentation, but why?
It sounds like you are expecting the Jenkins plugin to produce the documentation. The Jenkins plugin merely copies files from the job's workspace folder to the build's archive area and provides a link to it. If your build steps don't produce Javadoc, then Jenkins won't be able to archive and provide a link to it.
Does your pom file include the maven-javadoc-plugin?
Are your build steps invoking a goal that includes Javadoc generation?
For example, "mvn jar" would compile Java and build the jar but not build the javadocs. Clearly you have executed a goal that executes the tests and provides a code coverage report, but that does not trigger the Javadoc goals either. You would need to make sure your build steps include a javadoc goal - i.e., mvn javadoc:javadoc. The standard goals can be found here: https://maven.apache.org/plugins/maven-javadoc-plugin/plugin-info.html .
I want to link an external URL to Jenkins pipeline. This should be accessible while the build is running. AnchorChain had been suggested in several pages and so trying to use it but the documentation is less explanatory for a newbie. I installed the AnchorChain Plugin and added the following in the pipeline script.
sh "echo 'File1 http://localhost:8080/api' > anchorChain.tsv"
When I start the build, the console output shows
+ echo webAppUrlFile http://localhost:8181/api
Now I want to add this link to the sidebar of the build job similar to an HTML Publisher report link. What are the next steps?
Make sure you're using tabs as delimiters between:name url icon as outlined in this post: Jenkins_wiki
Note: The icon field is optional. If you don't specify one, you'll get one by default. I was unable to specify one using an http:// address (another problem for another day) so I just omit the field and get the default icon.
In order to get the side-bar link to show up in your Jenkins job, you'll:
Install the AnchorChain plugin. Once it's installed (and you've restarted Jenkins),
In your Job config (Build Section) in an execute shell, you'll add the output to the AnchorChain.tsv:
echo "Artifacts ${ARTIFACTS_URL}" > AnchorChain.tsv
In your Post Build Actions section, you'll add the Anchor Chain action
Add your file reference to the File name field:
Try out a build. Result after the build depicted in screenshot below.
I wonder if it is possible to remove only one build (including artifacts) from job workspace.
I tried to "Delete Build" in Build History but all it does is remove build reference from Build History table. I know I can ssh to a server and delete files from the command line but I am looking for a way to do it from Jenkins web interface.
After installing Workspace Cleanup Plugin I am able to wipe out current workspace but I want to keep my other builds in the workspace.
In your Jenkins instance, to be able to have folder/per build - set flag "Use custom workspace" in your job's settings. Here is a brief help info from the setting description:
For each job on Jenkins, Jenkins allocates a unique "workspace directory."
This is the directory where the code is checked out and builds happen.
Normally you should let Jenkins allocate and clean up workspace directories,
but in several situations this is problematic, and in such case, this option
lets you specify the workspace location manually.
One such situation is where paths are hard-coded and the code needs to be
built on a specific location. While there's no doubt that such a build is
not ideal, this option allows you to get going in such a situation.
...
And your custom directory path would look like this:
workspace\$JOB_NAME\$BUILD_NUMBER ~> workspace\my-job-name\123
where $JOB_NAME will be "my-job-name" and $BUILD_NUMBER is the build number, eq. "123".
There is one nasty problem with this approach and this is why I wouldn't recommend to use it - Jenkins will not be able to reclaim disk space for outdated builds. You would have to handle cleanup of outdated builds manually and it is a lot of hassle.
Alternative approach, that gives you more control, tools and is able to keep disk space usage under control (without your supervision) is to use default workspace settings and archive your build output (files, original source code, libraries and etc.) as a post-build action. Very-very handy and gives you access to a whole bunch of great tools like, Copy Artifact Plugin or ArtifactDeployer Plugin in other jobs.
Hope that info helps you make a decision that fits your needs best.
I also use "General/Advanced/Use custom workspace" (as in #pabloduo's answer) on a Windows machine with something like:
C:\${JOB_NAME}\${BUILD_NUMBER}
Just wanted to add a solution for getting rid of the build job's workspaces.
I use Groovy Events Listener Plugin for this.
Using the plug-in's standard configuration I just use the following Groovy script:
if (event == Event.JOB_DELETED){
new File(env.WORKSPACE).deleteDir()
}
And now the custom workspace is deleted when the build job is deleted.
Just be aware that this would also delete non-custom workspaces (because the event is triggered for all jobs on your Jenkins server).
Does any one have any idea what could have happened to Jenkins Email-ext? We have had this plugin working just fine for over two years and all of sudden our entire configs for this plugin have disappeared from all of our projects. We tried to uninstall and re-install the plugin but that didn't make any difference.
Once you install this plugin there should be a checkbox under "Post-build Actions" section in the projects config page to enable it but this option is not shown any longer here. Any idea?
Thanks!
This issue was fixed by following the below steps:
Uninstall email-ext plugin from Jenkins
Stop Jenkins services. (Run > Services.msc) find Jenkins and stop it
Go to Jenkins home (base folder) > Plugins and remove any instances of email-ext plugin (e.g. C:\Program Files (x86)\Jenkins\plugins)
Restart Jenkins
Install email-ext plugin again
And now everything should be working OK again!
if you haven't upgraded your jenkins then the issue might be a different one , just to make sure email configuration section has completely removed from your job , check the config.xml of your jenkins job for the keyword [email-ext].
how to check job's config.xml from GUI ?
simple click on configure link of your job you will be redirected to something like below
http://yourserver/job/jobname/configure
now change the last part of url [configure to config.xml] resulting in something like below
http://yourserver/job/jobname/config.xml
now search for keywords like email and email-ext , if you did not find anything then email-ext plugin is not functioning or its has completely removed the email configuration from your job , if you find an entry , do a uninstall /install and then try a restart of jenkins might resolve your problem , or else you can try the option of reloading configuration from disk.
I noticed that if you use Jenkins with the SVN or CVS option, a changelog.xml is created for each build that contains the author and the commit message for that build.
Unfortunately, in my setup, I am not using SVN or CVS, so I am unable to take advantage of the changelog parser. I was wondering if it was possible to create your own changelog with the same format (like the SVN XML changelog) and then point Jenkins to it during the build process. This way, when someone clicks on changes for the build, they'll be able to see what changed and who changed it.
I've tried just creating a changelog.xml and then updating build.xml to use the SVN parser, but two issues that I've noticed:
1) You have to reload configuration files to get it to show up
2) Build.xml doesn't appear to be created until the job is complete
There is some information on the changelog parser, but it doesn't seem that you can just access it during a build step: https://wiki.jenkins-ci.org/display/JENKINS/Change+log
Maybe a system groovy scripts would be a good direction (groovy script plugin). Just add a new script as your build step. You can access your AbstractBuild object by running the following code:
import hudson.model.*
import hudson.util.*
import hudson.scm.*
def thr = Thread.currentThread()
def build = thr?.executable
I'm trying to solve a similar problem currently, but my use case change a bit. I try to copy the changes from Upstream project in the similar way that BlameSubversion plugin does. Unfortunately I can't use the mentioned above SCM plugin because it doesn't work with post-commit-hook, so I have to write my own solution.
Take a look at copyChangeLogFromTriggerJob and copyRevisionFromTriggerJob methods to get know how BlameSubversion does that.
I'm able to copy changes and revision but I'm still fighting with ChangeLogParser.
I would be gladfull for any help as well.