I am working on the jenkins v2.289 and i want to edit the bash script that i have already test. But on the interface i can't found my old script to edit it.
I work on CentOs
enter image description here
You should provide more information, is that a previous pipeline that you have created and after some run you want to edit the pipeline? or is this a new pipeline?
On an existing pipeline in your screenshot you should be seeing your shell like this:
if it's a new one you should select from the drop-down menu in "add build step" "execute shell".
Related
Currently we have a project that contains a 'pipeline script from SCM', but we would like to add an editable email notification for the results of these builds. To do this, we need to create a 'Freestyle project'. I can not find the option 'pipeline script from SCM' in a Freestyle project and I have no knowledge of Jenkins whatsoever. I have tried clicking on everything that contains "Git" and "pipeline", but I did not get any further.
Does anyone have an idea how I can easily convert this pipeline script from SCM within a Freestyle project?
I currently start the build of this project within the Freestyle project, but then I can not refer to the html results of the other project.
User needs the ability to perform particular action in Jenkins UI on any of the job builds that are already finished with access to the build`s ID.
For each build in history there is menu with items "Changes", "Console output", "Delete build", "Rebuild" etc. Can I add a custom command into that menu using an existing plugin? The command will be "pass build ID to a script on Jenkins machine and launch the script" or at least "put build ID to a file" or "pass build ID to another job and launch it".
Is there any plugin that can do that?
The workarounds I am currently aware of are the following:
a separate Jenkins job that gets required build ID (needs launching another job, correct copying of the build ID)
rename build using menu item "Edit Build Information", then a script/cron job on Jenkins machine will do what it needs to (requires correct renaming)
putting a link to script into html report
artifact an html with the link to script
Looked at the plugins like "batch-task", "sidebar-link" etc., but all work on job level and not on build level.
P.S. It is a free-style Jenkins job, pipeline / Groovy has not been used.
Perhaps a Groovy script might help? How can it look like and how to make launching such script user-friendly (ideally with one button)?
I have a Jenkins job I want to use to run automation on a build created in another job. I want the user to specify that build job's build number using the drop-down box created by the Run Parameter plug-in and then have the automation job copy the artifacts from the user-specified build job.
These are the settings for Run Parameter:
Name: BUILD_SELECTOR
Project: Foo
Filter: All Builds
The user then selects a build like which is saved to BUILD_SELECTOR like "https://blah.com/job/Foo/4/"
Then later in my job, I have Copy artifacts from another project and I want to copy the artifact from the job selected above:
Project Name: Foo
Which build: ?
This is where I get stumped. I have tried the URL above as a permanent link and also tried stripping out the "4" above for Specific build, but nothing seems to work. How can I use that value to do what I need to do?
As stated in https://issues.jenkins-ci.org/browse/JENKINS-21519
You can use ${BUILD_SELECTOR_NUMBER} to get just the build number which you can use with specific build.
I have two Jenkins builds, one for compiling and one for deploying.
The developer wants to be able to choose a build from the compiler build when running the deploy build, not always run the most recent build.
What I am after is a method of populating a choice parameter for the deploy build with a list of successful\unstable builds from the compile build.
I will then use the the option listed in the parameter to deploy that artifact.
Using the Dynamic Parameters plugin
In your promote job:
[x] This build is parameterized
Add Parameter
Dynamic Choice Parameter
Set Name to whatever
Paste below into Choices Script
import jenkins.model.Jenkins
import hudson.model.AbstractProject
import hudson.model.Result
import hudson.util.RunList
AbstractProject<?, ?> otherJob = Jenkins.getInstance().getItemByFullName("otherJobName", AbstractProject.class)
RunList<?> builds = otherJob.getBuilds().overThresholdOnly(Result.SUCCESS)
def list = builds.limit(5).collect { it.number }
Screenshot from wiki page:
As Dynamic Parameters plugin is no more accessible. You can use Active Choice parameter plugin in Jenkins.
Now you can list all successful Jenkins builds as parameterized option in Jenkins Job/pipeline
Follow below steps to access the list of successful jobs [as dropdown list]
In job configuration [General section] select this project is parameterized
Select add parameter as "Active choice parameter"
Give name for parameter
Select groovy script and paste below code in groovy script text box
return jenkins.model.Jenkins.instance.getJob('<Jenkins-job>').builds.findAll{ it.result == hudson.model.Result.SUCCESS }.collect{ "$it.number" }
It worked awesome without without powershell and BASH
No need to process Jenkins API and filter JSON output
One option is to use the Promoted Builds plugin to mark a specific build to be deployed. This moves the choice from the deployment build into the compilation build. Select the Promote builds when... option in the compilation build and set up how you want promotion to work. The developer could choose (or automate) the build to promote. In the deployment build, the Copy Artifact plugin can grab the appropriate build (based on a permalink to the latest promoted build).
As far as I know, it is not possible to populate the choice parameter. However, you don't need to always use the newest build. I assume that you use the copy artifact plugin. This plugin provides the "Build selector for Copy Artifact" parameter. You still need to enter the build number manually, but when deploying you have all the standard choices, like "Latest successful build", but also "Specific Build". You need to enter the number and don't have a drop down, but I got my deployers trained well enough to enter the build number.
In jenkins, we have a requirement like having the options that appear under build step like (say)
Execute Shell
Execute commands over ssh
Invoke Ant
To appear in the post build section. And it should do the same work as it did under build section.
I made all the options in build section appear in UI under post build section by doing it.getbuilddescriptors in config.jelly of my plugin. And it appeared in my jenkins UI under post build section as a hetero list.
But the problem is I don't know how to make it work as a bost build step.
For shell we did
Shell s = new Shell(command);
s.perform(build, listener, launcher);
and it worked.
If this is possible, then it may even be possible for all build section items. Is there a direct way to do without doing as I did for 'Execute shell'?
You may consider looking at https://wiki.jenkins-ci.org/display/JENKINS/Any+Build+Step+Plugin
They provide ability to use Build Steps as Post-Build actions, and vice-versa