Not able to run terraform from jenkins - jenkins

I am trying to run a terraform command from jenkins pipeline but I am getting an error stating that, "terraform command not found". I have installed terraform plugins as well as terraform in the system where jenkins is also installed. Please help.

I haven't used Jenkins' Terraform plugin yet but have you considered to run inside a docker container which has preinstalled terraform?

Related

Jenkins using aws is not recognized as an internal or external command - Windows 10

Jenkin Project - I configure the Build setup in Batch file in below statement
aws s3 cp ./dist/first-ci-project s3://first-ci-cd-project --recursive
but result is
'aws' is not recognized as an internal or external command,
But Command Prompt i run the above command its working good. Pl help me.
Are you running the aws command in a jankins slave? If so please check whether aws cli command tool is installed on the slave and the location of the aws cli is added to the environment variables.
If you are running on the jenkins master, same as above. Please check if you have added the aws cli folder location is added as environment variable under jenkins master.
I had the similar issue, I had make sure that the user with which aws CLI is installed is same as the one which Jenkins is using during the runtime

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

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

Jenkins does not come with Docker?

I'm starting to learn Jenkins and I'm following the guide on their website. This is a new Jenkins install, installed all the recommended plugins. I've created a valid Jenkinsfile, initialized git in the project folder, and I'm trying to build, however, Jenkins doesn't seem to find Docker. When building, I get:
/Users/me/.jenkins/workspace/Test_pipeline_master#tmp/durable-ba04c9ec/script.sh: line 1: docker: command not found
Am I supposed to install a separate docker installation? I'm checking and I do have Docker plugin:
My Jenkinsfile has:
pipeline {
agent { docker { image 'node:7-alpine' } } #also tried with python:3.7 to no avail
...
What am I missing?
Yes, you need to install docker if you are planning to use docker.
Once installed, you also need to add the user 'jenkins' to docker group.
See these two links for more help.
(if you are installing jenkins on other OS, search for appropriate help for installing docker for that OS)
https://phoenixnap.com/kb/how-to-install-docker-on-ubuntu-18-04
https://www.edureka.co/community/7764/trying-docker-jenkins-pipeline-facing-jenkins-pipeline-socket

How to configure Ansible in Jenkins Global Tool Configuration?

I am running Jenkins on Docker container. I have installed ansible on my computer and Ansible plugin on Jenkins as well. which ansible is /usr/local/bin/ansible. How can I configure my system's Ansible on Jenkins Global Tool Configuration (http://localhost:8080/configureTools/) as the /usr/local/bin/ansible is not being recognized by Jenkins.
"/usr/local/bin/ansible is not a directory on the Jenkins master (but perhaps it exists on some agents)" is the error I get when I try to put the ansible path
ansible should be installed on the server where you want to execute the ansible via Jenkins commands. (but perhaps it exists on some agents) -- this line means that in case there are slave registered to jenkins with ansible installed you can use them --> this error is generic. Also you can't use your local machine's ansible. Ansible tower is one such tool you can use but that requires custom installation on linux server

How to run a Jenkins job inside a windows docker container

I am trying to run a jenkins job inside a windows docker container. I have successfully created an image with windows server code docker image which will have MSBuildEngine 4.7.
The problem I am facing is I am not able to run a Jenkins job inside that container.
I am able to do it easily with linux environment.
The actual problem is, Jenkins first puts a shell file which will have the command to run the container and inspect it.
How do I tell Jenkins that my environment is not Linux and it is Windows.
Note: Searching in google does not help now a days. So I directly reached out here
I am working on this issue as well. I am finding that the (maybe just a) underlying issue is how Jenkins tells Docker to mount a volume to the container. I have yet to get around this issue.
edit:
There's a PR addressing this issue and I tested the fork with both Linux and Windows slaves to work as we intend.
Download Rbutcher's fork of the plugin:
git clone https://github.com/rbutcher/docker-workflow-plugin.git
Change to the working branch:
git checkout feat/windows_slaves
Build the plugin:
mvn -DskipTests clean install
Manually import into Jenkins:
Manage Jenkins> Manage Plugins> Advanced>Upload Plugin and select ./target/docker-workflow.hpi.

Resources