How do I pass parameters from Jenkins to Rundeck? - jenkins

I am new to Rundeck and I managed to create project, nodes and jobs in Rundeck
I created a simple parameterized job in Jenkins and I input IP Address (eg 10.10.20.30)
I would like to pass $IP_ADDRESS from Jenkins to Rundeck.
I tried adding ip_address=$IP_ADDRESS in Jenkins post-build action of Rundeck but I am unable to echo IP_ADDRESS from Rundeck
I googled a lot but I did not get enough information. Any help is highly appreciated

You can point to Rundeck job with options using Rundeck API like this: https://stackoverflow.com/a/54593735/10426011 but the best way to integrate Rundeck with Jenkins is to use the Rundeck plugin for Jenkins, check this: https://wiki.jenkins.io/display/JENKINS/RunDeck+Plugin

Related

Kubernetes Cron Job to trigger a Jenkins pipeline

My team to to create a cron in Kubernetes/OpenShift that will trigger our Jenkins pipeline that we have set up. We tried doing the triggers{} syntax and the build periodically option on the Jenkins UI, however these are unreliable for us since whenever Jenkins restarts, those build triggers on Jenkins get removed.
There is two approaches you could use here:
Make your Jenkins stateless with the Configuration as Code plugin
Use a curlimages/curl container to trigger a job via the Jenkins REST API

Containerization of Jenkins pipeline

I have a Jenkins pipeline for APIC(API Connect), which downloads the code from git hub, validates the code, deploys the code on API Manager(present on Cloud Pak), tests it using Soap UI and finally stores the test report on Nexus.
I now have to containerize this entire pipeline, so that it could be put on any server or any machine and can be started as a self sufficient service.
I understand that I would need to use docker for this, push the images for the tools used and then have some sort of interconnection between the images.
Please help me if my understanding is correct and what should be the approach that I should follow. Any reference links are appreciated.
Thanks in advance.
You can make use of Jenkins DSL Plugin to create a seed job of your pipeline and then, you can make use of Docker container as build slaves for Jenkins.
So, whenever you run the seed job, the child jobs will run on the docker container slaves.
You can refer to this stackoverflow post or Jobs as Code with Groovy DSL to learn more about Jenkins Job DSL.

Running jobs in Jenkins slave node using Groovy script

I am confused about whether a Jenkins job can be run using Groovy script in the slave node. I referred a StackOverflow answer [1] which says that System Groovy script jobs can be run in master and not in slave, and to run a job in slave it has to be Groovy script rather than System Groovy Script. Can someone clarify me whether we can run a slave job using System Groovy Script? Since I am trying through Groovy script I am unable to access few Jenkins instances. Please suggest me a better way with an explanation. Thanks in advance
I have finally found that it is only possible to run jobs in Jenkins slave node using Grovvy script. The system groovy script runs inside the Hudson master's JVM. Thus it will have access to all the internal objects of Hudson, so we can use this to alter the state of Hudson. It is similar to the Jenkins Script Console functionality.

How to set in Jenkins a credential id for Perforce SCM before starting the job in a slave node?

Let me explain what I have before exposing my question. I have a Jenkins with a seed project that creates jobs from groovy scripts using the Job DSL plugin.
I have a job that uses Perforce as SCM. This has been setup from the groovy and the Perforce credentials have been also set using the id passed to credential() inside scm{perforce{credential("perforce1")}}
This job is configured for running only in my slave nodes.
What I want to do is: I would like the slave node, before the SCM step, sets the credentials for Perforce based in something like environment variable (ex: NODE_SCM) so when launch the build process, the node would set the credentials for using it before the Perforce SCM starts the process.
The credentials for Perforce is now in Jenkins but could be created in runtime or something like that if it is possible what I want to do.
Example: Imagine I have two credentials stored in my Jenkins (perforce1 and perforce2). The variable NODE_SCM would be one of those ids and set it for building the job in the slave node.
I donĀ“t know if I explain correctly what I want to achieve.
Thanks for your attention in advance.
Best regards

How to add build server details in Jenkins pipeline?

I am having Jenkins in one server and my build server is different. How to point build server in Jenkins pipeline so that my application will build in build server
Using grade and java.
Do we need to use node('Build 1') inside stage?
Suggest me some sample code please.
In Jenkins, your build server called slave machine or Jenkins nodes, which you need
Firstly add this "buildserver" into Jenkins nodes in advance, then you will get node name (or label them like ubuntu-buildserver), see one jenkins distributed build blog
Secondly in scripted pipeline you specify/reference this name in node
node("ubuntu-buildserver")
If you use declarative pipeline, check syntax#agent part.
It is similar for other global configuration like credentialsId, you need define those parameters in jenkins and refer to use them in your pipeline script.

Resources