How to write jenkinsfile that will access openshift and run few commands - jenkins

I am new to Jenkins, can someone help me to write Jenkinsfile that access openshift run few of commands, and return the report
I know commands to run manually in open shift but don't know how to do in Jenkins

There are a few good introductions available on how to access OpenShift using the OpenShift Jenkins Plugin or on how to run generic commands using sh:
Using OpenShift Pipeline Plugin with External Jenkins
Building Declarative Pipelines with OpenShift DSL Plugin
More generic: Jenkins Pipeline: running external programs with sh

Related

support with Jenkins configuration

I installed Jenkins on my -AWS EC2 Ubuntu- and on the same server I'm running Docker. what I'm trying to do is to build a pipeline via Jenkins on that EC2 Instance. my jenkinsfile stored on Github
When I run the pipeline I get the following error:
Jenkins’ doesn’t have label ‘docker'
How to solve this problem?
I went to manage Jenkins -> global tools and also to configure system
but non of these solve the problem.
Any suggestions?

Pipeline by using Jenkins with private SVN repository

I am trying to implement CI/CD pipeline for my microservice oriented project by using Kubernetes and Jenkins. I am using my code repository on my on-premise server. I created one SVN repository on my server.
I am interested to know, can I use my private SVN code repository with Jenkins?
The reason for my doubt is because every example is showing the creation of pipeline with Jenkins and GitHub project.
You can use the shell command in your pipeline. So you are free to use SVN with Jenkins:
https://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-cli-main.html
Some info there:
Run bash command on jenkins pipeline

Jenkins Pipeline file

I am in the process of writing a declarative jenkinsfile to build a pipeline project. Some of the steps within a few of the stages will require some remote commands to be run. The remote ssh sites have been configured in the main jenkins configuration.
How can I declare these steps within my jenkinsfile? I know I can run shell commands locally using sh but it's the remote servers that i need to know about?
You need to install ssh-agent plugin then you will be able to execute remote commands using ssh. Check this for examples

Jenkins Pipeline using Openshift

I am trying to create a Jenkins pipeline on Openshift, that automatically runs a Jenkins service when we start the pipeline build. I referred few templates online and created a Jenkins pod and a pipeline. But whenever I try to run the pipeline, It shows build status as "not started.
Later, I created a standalone Jenkins service in Openshift, created a Jenkins file in open shift and tried executing it. I encountered authentication issues while connecting with Openshift from Jenkins.
Can anyone guide me, if I am missing something or any other working templates for a pipeline?
Thanks
It’s because of permissions
Jenkins runs with Jenkins user and openshift doesn’t know how to connect to it
Create a new service account in openshift jenkins

How do I pass on my build file from Jenkins to Saltstack master

We have a Jenkins system to automate build from Github, now we are implementing a Saltstack system. So I need to integrate my Jenkins with Salt-master so that it passes all the new builds to the master which then sends it across the salt-clients(minions).
The saltstack setup is in AWS cloud and and the Jenkins machine is outside the cloud in a local setup.
You could enable the salt-api and using the following plugin: https://wiki.jenkins-ci.org/display/JENKINS/saltstack-plugin then all of your jenkins builds can execute states / orchestrations etc. to any minions on a per job basis.
Another way of doing this is to have a minion running on the salt-master and install the jenkins slave on the same box. Then restrict the jenkins jobs to that jenkins slave and execute the commands as if you were at the command line. NOTE: this option requires a bit more configuration.

Resources