I've used Jenkins a bit here and there but this is my first time to create a pipeline in Jenkins. What is the preferred tool these days for creating a new Jenkins pipeline? Here's the main Jenkins docs page for pipelines:
https://www.jenkins.io/doc/book/pipeline/
The url states:
get started with Pipeline - covers how to define a Jenkins Pipeline
(i.e. your Pipeline) through Blue Ocean, through the classic UI or in
SCM
I viewed the Jenkins Blue Ocean docs page and it has this info towards the top of the page:
Blue Ocean status Blue Ocean will not receive further functionality
updates. Blue Ocean will continue to provide easy-to-use Pipeline
visualization, but it will not be enhanced further. It will only
receive selective updates for significant security issues or
functional defects.
That passage gives me the impression that Blue Ocean may be in a somewhat deprecated state as the tool for creating new pipelines in Jenkins. Is that the case? What is the preferred tool these days for Jenkins admins to create a new pipeline in Jenkins?
You should avoid using Blueocean as it's not going to receive any updates from Cloudbees.
Having said that, Jenkins Pipeline has a declarative syntax. So it doesn't really matter how you create it as long as you adhere to the correct syntax. The correct question you should be asking is where to store your Pipeline. Basically, you can embed the Pipeline in the Jenkins Job itself, or read the Pipeline from an SCM or you can add your pipeline as a shared library.
Related
I have a jenkins pipeline which I have written using Declarative pipeline syntax. The pipeline is running fine. I am able to view steps and detailed steps.
Now, the client has a requirement where they want to see these steps in a report fashion. They want to show/handover these reports to their audit firm. The thing is they don't want to give their audit firm jenkins access. The audit firm should be able to view whatever is going on in the pipeline.
So, I made the console output of the build in a pdf file. Now, they want to see the steps too.
First is the simple pipeline steps view,
Second is the detailed pipeline steps view,
Now I have to display this in another file.
Is there a plugin to export these steps in a visual format?
If not using a plugin, is there an API from which I can extract the text of these steps? I see they are not available in the /api/json endpoint of a build.
Anything else that can be done?
Thanks.
BlueOcean API has the info you need at
${YOUR_JENKINS_URL}/blue/rest/organizations/jenkins/pipelines/${JOB_NAME}/runs/${BUILD_ID}/nodes/"
Is there a way where to store some metadata from Jenkins pipeline job, e.g:
We have a Jenkinsfile which builds a gradle project, creates docker image and pushes it to google cloud
Then a "Subjob" is launched which runs integration tests (IT) on that docker image. Subjob receives a couple of parameters (one of them - the generated docker image name)
Now sometimes that IT job fails, and I would like to re-run it from the main job view, so idealy:
we have a plugin which renders a custom button in blue ocean UI on the main job
By clicking that button a subjob is invoked again with the same parameters (plugin queries the jenkins api, get params of this job, and resubmits the subjob).
The problem ? How to get/set those parameters. I could not seem to find a mechanism for that, expect artifact storage. I could get away with that by creating a simple json/text file and uploading it as artifact, and then retrieving it in my plugin, but maybe there is a better way?
Stage restart is not coming to Scripted Pipelines so that does not look like ant option.
Maybe you can use the Jenkins API to get the details of the build?
https://your_jenkins_url.com/job/job_name/lastBuild/api/json?pretty=true
Instead of lastBuild you can also use the build number or one of lastStableBuild, lastSuccessfulBuild, lastFailedBuild, lastUnstableBuild, lastUnsuccessfulBuild, lastCompletedBuild
There is a parameters key there with all parameter names and values used in the build.
More details on https://your_jenkins_url.com/job/job_name/api/
Also, any reason you can't use the replay button in the IT job?
How can I create a delivery pipeline view for jenkins pipeline using jobdsl.
All I could find was deliveryPipelineView, which isn't the same view, any information on this would be useful
Delivery Pipeline views for Jenkins pipelines does not seem to be supported by JobDSL at the moment (1.64).
The Job DSL class DeliveryPipelineView only supports traditional jobs with upstream/downstream dependencies. The reason for this is that the Delivery Pipeline plugin uses different views and data models under the hood to render the pipeline views for upstream/downstream jobs and Jenkins pipelines, much due to the different nature of the underlying data models used in Jenkins.
The traditional view, which JobDSL supports will generate a se.diabol.jenkins.pipeline.DeliveryPipelineView configuration, while views supporting Jenkins pipelines are modelled using the se.diabol.jenkins.workflow.WorkflowPipelineView class in the Delivery Pipeline plugin.
Current DeliveryPipelineView template in JobDSL: https://github.com/jenkinsci/job-dsl-plugin/blob/master/job-dsl-core/src/main/resources/javaposse/jobdsl/dsl/views/DeliveryPipelineView-template.xml#L2
If you append /config.xml on the URL of your view which is based on Jenkins pipelines, you will notice the XML is of the type se.diabol.jenkins.workflow.WorkflowPipelineView.
The solution at the moment would be to handcraft the necessary config.xml and feed it to Jenkins yourself.
For me, the deliveryPipeLineView method create exactly a delivery pipeline view..
Here an exemple :
deliveryPipelineView('name-pipeline') {
description('description-pipeline')
pipelineInstances(1)
showAggregatedPipeline()
columns(1)
sorting(Sorting.TITLE)
updateInterval(2)
enableStartBuild()
enableManualTriggers()
showAvatars()
showChangeLog()
pipelines {
component('name', 'init-job')
}
}
See the doc on gitHub for more details : https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-DSL-Commands
I try to set up a public display on our department floor to present the current status of the Jenkin's maintained projects. Therefore I'm cycling through a session of Jenkins web pages like the Blue Ocean Pipeline overview or the detailed build history of particular pipelines.
Blue Ocean Pipeline Build History
Additionally I would like to show the detailed page of the last build step of a pipeline.
Build details of a pipeline
Unfortunately the url that is been called uses the build number which I don't have on my script side. Is there a way within Blue Ocean to call for the last detailed build page in depended of the build number.
* instead of .../blue/organizations/jenkins/Playground_RTM/detail/Playground_RTM/112/pipeline
* something like that .../blue/organizations/jenkins/Playground_RTM/detail/Playground_RTM/last/pipeline
Any ideas?
I could not find a direct dynamic URL in the blue ocean for the last build.
If somebody is looking for providing a quick access link, they could provide link to activity page for a particular branch in blue ocean.
https://<host-name>/blue/organizations/jenkins/<job-name>/activity?branch=<branch-name>
Or provide the last build page URL for classic Jenkins by using the lastBuild keyword.
I am using the Delivery pipeline plugin for grouping my jobs into stages.
Currently, there seems no mechanism to directly go to a particular older pipeline instance in the view.
I wanted to provide a provide a mechanism(posssibly a link) in the Initial job(JobI) of the pipeline so that whenever I click on a particular build of the JobI, it should redirect me to that particular pipeline instance of the pipeline view directly.
I also tried to achieve the above behavior via some other pipeline plugins i.e Build pipeline etc. but no solution.
The idea is to make the view easy to use for a user,so that he does not have to take the pain of scrolling through all the instances to get to a particular instance.
I want to replicate the behavior of the "builds in the jobs" for the "versions of the view" or similar to that.
Any help/suggestions would be great.
Try Build Graph View Plugin to view the executions of downstream builds.
But this plugin doesn't have a grouping of jobs as stages, it is plain flow graph.