Jenkins Manual Step by remote call - jenkins

I am using Jenkins Build Pipeline plug-in for build pipelines. In mine pipeline I have manual step ( Build other project (Manual Step) ). When I trigger build it stops on this manual step (it's ok) and now I want to run it. But I don't want to trigger it via jenkins GUI but via call from some other application.
Example (Jenkins jobs pipeline):
Build -> Deploy Test -> (manual) Deploy Production
now I want second app with big button "Test ok, deploy on production" and via it call the jenkins manual job.

Yes, have a look at this: it´s explaining how to use Jenkins´ Webservice API to call a Build from outside of jenkins:
Calling a jenkins build from outside of jenkins?

Related

Jenkins - How to just trigger action when push happens to Bitbucket repository?

I have connected Bitbucket to my Jenkins on vps (where I have BitBucket plugin to trigger events when changes are pushed/commited to Bitbucket).
So when Push happens on BitBucket repository, Jenkins starts build (that takes about 10 seconds). After that, the Post-build event happens, where I use specific command (sending changed files to somwhere). However, I am only interested to run that specific command, and I don't need building at all (so I could save 10 seconds).
Any way to do that?
p.s. Here is what config I use: https://i.imgur.com/7JDy8Ex.png
Based in the screenshot the Jenkins job does the following
Triggered on Source code change
Runs the build step ( which runs ssh publisher plugin)
Post build
If you just want to run the command you have in post build. Remove the ssh publisher step. Add a new build step that executes command/shell and add your current post build command in the step.

DevOps Continuos Delivery for Java Script

Can i use Jenkins integration for DevOps Continuos Delivery Pipeline for JavaScript code builds?
I am trying to build/propose a solution for integrating Jenkins tool and to remove manual code build and deployments to remove the manual effort for my team.
Generally in Jenkins, you can use the below:
Build -> Automated Test -> Dev Deploy -> QA Approval -> QA Deploy
The Seed Job is the one which will be creating other Jenkins job automatically but the seed job itself will be configured manually. The Seed Job will read the DSL script, parse those and create appropriate Job configurations in Jenkins.
After the seed job runs successfully, we will have a job created for our sample app.
The Seed job will create the following set of jobs which will eventually be part of the pipeline. The Seed job will also create a Jenkins pipeline view.
Build: This job includes the configuration for the building project, job triggers, scm location, jdk version to use, maven goals, artifact upload to repo like Artifactory.
Test: This job can call test suites and decide to call a downstream job or not.
Dev Deploy: Simple job with a trigger to the Promotion Job if the deployment was successful.
This job can call the script to perform a deployment or use tools like Bamboo or Urbancode.
Usually a Dev deploy doesn’t need promotion, but we can add that step if required.
QA Promotion: This job includes a send email notification to the person/group responsible for approval. The email contains a link for promotion.
The Promotion Email link can look like this: http://localhost:8080/XXX/XXXXX/XXX
The same can be done for the UAT and Prod:
We can chain multiple Promotion Jobs and Deploy jobs to accomplish the need for another environment, for e.g. UAT Promotion -> UAT Deploy ->PreProd Promotion -> PreProd Deploy -> Prod Promotion -> Prod Deploy
And here for all the above mentioned processes it can be done via Jenkins tool
Also yes, to answer your question you definitely can use Jenkins integration in Devops Pipeline.
If you are building your solution in cloud or in any domain servers then you might have to get the Jenkins integrated in the same environment.

Using Jenkins for Continuous Deployment of WebApp - Publish Artifacts to Server

We are searching for a CI and CD Solution for our WebApp based on NodeJS/Meteor.
Our Process should be:
On each Push to Master/ Pull Request/ Merge to Master do the following:
Checkout
Run Code Style Checks (coffeelint, scsslinter, etc.)
Build Code
Run Tests
Generate Tarball-Archive
Deploy archive to Developmet (Quality Management) Server, extract and run
next step would be manual testing of the app on our dev server.
when we think it is deployable, I want have a button in jenkins like "Deploy these Artifacts NOW to Live-Instance". How can I achive this? Also Nice would be something like deploy these artifacts at 2am to the live instances.
From Checkout to deploy to dev-server is already implemented in jenkins. What we need now is a button "deploy this artifact to live"
You need another job to get this working. The other job takes the artifact from the build job and deploy it wherever you want.
There is no possibility to include such behavior in the same job.

Send command from TeamCity to run automation tests on Jenkins

Is there a way to add a build step in TeamCity which sends a request to Jenkins server, run some automation test scripts in Jenkins and sends back a response to Teamcity.
The idea basically is to automate the whole deployment process which also includes running of some automation tests created using python scripts (which will be done on Jenkins).
I am not sure if this is the best way of doing it but are there any better ways to achieve this? Also any hints on how to send command from Teamcity to Jenkins?
You can make an http request, as mentioned in the comment to start tests on Jenkins.
As for publishing the results bach to TeamCity, the possible solution might be:
after tests are done on Jenkins, publish the results that can be accessed externally (by TeamCity) and interpreted / reported by TeamCity (either in any of the supported formats), or manually, by the script, that will be run by TeamCity, using service messages
create a build configuration that will process the tests after the Jenkins build
set up a URL build trigger plugin, configure the trigger for the created build configuration. Point the trigger to the address where results are published. As soon as the content published is changed, the build will start and you will be able to download the tests results to TeamCity and process them
Got an easy to implement solution for the first part i.e. sending command from Teamcity to Jenkins
Using CURL:
Install/copy Curl to the Teamcity agent.
and then in your TC build configurations, create a new Command line build step similar to below (modify the parameters to your needs)
curl --user %jenkins_user%:%jenkins_pwd% -X POST http://%jenkins_instance_withport%/job/%jenkins_jobs_name%/buildWithParameters?token=%jenkins_token% --data "Build_Number=%build.number%"
e.g: curl --user admin:password -X POST http://jenkinssever:2123/job/test-build-image/buildWithParameters?token=rtbuild --data "Build_Number=1.2.0"
Here i could even pass the build number to Jenkins by using "-- data"
Do the below under Jenkins build configuration:
In Jenkins configuration:
In Jenkins configuration, update the below values:
"This project is parameterized"
Name: Build_Number
Default Value: 1.2.0
"Trigger builds remotely"
Authentication Token: rtbuild
Optional: for setting build number
"Set Build Name"
Build Name: #${Build_numuber}
done and you are good to go.please do let me know you if you have more questions.
the above is the implementation of the Initial comment
I think I found a way while trying to solve similar use-case, did it for batch files in Teamcity build steps. for Jenkins, we have to modify accordingly.
Also is there any specific reason for using Teamcity and Jenkins simultaneously, unless you are making use of already created Jenkins build?
Steps:
Get CLI based command for Jenkins:
https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI
you can achieve in two ways
Method 1:
As build step is in current build.
Create a build step before your current step and trigger the Jenkins build using CLI
Based on the return value of the Jenkins build step, next step will execute
Method 2:
create a new build with above CLI step and add a dependency in your primary build.
so whenever the primary build is started, it will start the dependent CLI jenkins build. and once the dependent build is completed, will return success/failure, based on that the primary build will start.
i haven't tested the CLI of Jenkins but as Teamcity supports the steps and dependencies structure, expecting this will work.
will keep posted once i implement it.

Running sequentially job tasks on several environments using Jenkins

I'm new to Jenkins. I'm trying to implement a specific scenario in a single job to build mobile applications using Jenkins.
In a single job I want to launch several tasks sequentially:
Task 1 (Windows) ---> Task 2 (Windows) ---> Task 3 (Windows) ---> Task 4 (Mac OSX)
Each job will be dedicated to a single project. Passing results from a task to another can be realised through the workspace, but it seems that job tasks must all run on the same environment. Is there any plugin that will let me run some tasks of the job in a particular slave ?
Thanks in advance
You could use trigger builds remotely on your slave jobs.
Then from the master job you can execute slave builds using curl. Like this:
$(curl --user "username:password" "http://jenkins.yourdomain.org/job/JOB-name/buildWithParameters?SOMEPARAMETER=$SOMEPARAMETER&token=TheSecretToken")
TheSecretToken is the token password you specified on your slave plugins.
And username:password is a valid user on your jenkins. Don't use your own account here but rather a 'build trigger' account that only has permissions to start specific jobs.
Define a job for each task you have mentioned.
Have a slave on the remote machine(s) - presumably the Mac.
In each job, set the relevant host that will run it (you have a parameter for that).
Use the "trigger parameterized build" plugin to trigger the jobs in the correct sequence, and make sure you pass "Current build parameters" in that section.
This plugin will allow you to pass other values as well - read its help for more details.
Try this
Build flow Plugin
Multijob Plugin

Resources