Jenkins X: trying to execute 'jx boot' from a non requirements repo - jenkins

I'm trying to install Jenkins X on an existing Kubernetes cluster (GKE), using jx boot, but it always gives me the error trying to execute 'jx boot' from a non requirements repo
In fact, I have tried to use jx install, and it works, but this command is already marked as deprecated, but I see it's still the method to use on Jenkins X's GitHub page.
Then another detail ... I'm in fact creating the cluster using Terraform because I don't like the idea that Jenkins X creates the cluster for me. And I want to use Terraform to install Jenkins X as well but that would be another question. :)
So how to install using jx boot and what is a non requirements repo ?
Thanks

Are you trying to execute jx boot from within an existing git repository? Try changing into an empty, non-git directory run jx boot from there.
jx wants to clone the jenkins-x-boot-config and create your dev repository. It cannot do so from within an existing repository.

One thing I've noticed is that running jx boot in an existing repo without a jx-requirements.yml it asks if you want to check out the Jenkins X boot config.
Creating boot config with defaults, as not in an existing boot directory with a git repository.
No Jenkins X pipeline file jenkins-x.yml or no jx boot requirements file jx-requirements.yml found. You are not running this command from inside a Jenkins X Boot git clone
To continue we will clone https://github.com/jenkins-x/jenkins-x-boot-config.git # master to jenkins-x-boot-config
? Do you want to clone the Jenkins X Boot Git repository? [? for help] (Y/n)
I let it do this checkout, and then either let it crash or cancel it.
I can now go into the new repo, make changes to the jx-requirements.yml and run it as I want it to.

Related

How to include code from another repository in gitlab registry?

I have a shared registry (a docker image with tools installed for running my code) which is used by multiple repositories. I have created a new repository called LuaServer, which uses code from another repository called LuaDB. In LuaServer I have created a test which requires the code from LuaDB, this test is run in a pipeline on GitLab CI/CD in said shared registry. I get an error during the execution of this test, stating the following:
spec/serializer_spec.lua:36: module 'luadb.manager.AST' not found:No LuaRocks module found for luadb.manager.AST
Now I tried to directly clone the repository and set it up in the registry (a docker image basically which now has LuaDB), which did not seem to work as the error stays the same. Then I tried to include LuaDB as a submodule for LuaServer, but this still did not solve my problem. Is there a way to work this out?
Try using curl to get files from gitlab repo (check gitlab api)
Gitlab CI/CD pipeline when using it's runner (gitlab shared runners or custom runners) they use a default path that exists on $CI_PROJECT_DIR env variable. so you can clone you code (luaDB) under $CI_PROJECT_DIR/your_existing_code_luaserver

CI/CD integration problem when using google-cloud-build with github push as trigger for Cloud Run

I am trying to set up a CI/CD pipeline using one of my public GitHub repositories as the source for Cloud Run (fully-managed) service using Cloud Build. I am using a Dockerfile initialized in root folder of the repository with source configuration parameter initialized as /Dockerfile when setting up the cloud build trigger. (to continuously deploy new revisions from source repository)
When, I initialize the cloud run instance, I face the following error:
Moreover, when I try to run my cloud build trigger manually, it shows the following error:
I also tried editing continuous deployment settings by setting it to automatically detect Dockerfile/cloudbuild.yaml. After that, build process becomes successful but the revision are not getting updated. I've also tried deploying a new revision and then triggering cloud build trigger but it isn't still able to pick the latest build from container registry.
I am positive that my Dockerfile and application code are working properly since I've previously submitted the build on Container registry using Google Cloud Shell and have tested it manually after deploying it to cloud run.
Need help to fix the issue.
UPPERCASE letters in the image path aren't allowed. Chnage Toxicity-Detector to toxicity-detector

How can I allow "go get" or "go install" to pull from github inside a Jenkins Kubernetes pod executor?

I am running Jenkins inside a Kubernetes cluster and setup to spawn an executor pod with 3 containers: jnlp, golang and kubectl.
Using "golang" container, I would like to be able to pull dependencies from github using "go install"
However, I am getting these errors (my code is in /go/src/test-app):
cannot find package "github.com/andreid/test-app/controllers"
cannot find package "github.com/sirupsen/logrus"
and it seems unable to pull from github (though that's where Jenkins is pulling my code from and it's configured to do that using a developer oauth key that I generated).
It seems that the "jnlp" container handles the pulling of code successfully.
What can I do to allow "go install" to work as expected?
Thanks!
For posterity: when running Jenkins in a Kubernetes cluster with all the proper paraphernalia (Kubernetes pod agents, etc), there's no straightforward way to do this. You might expect agents will pick up github credentials setup in Jenkins, but they don't.
A quick way is to create a secret containing a github access token and mounting it as the env var GITHUB_TOKEN in the golang container used in the execution pod. YOu will need to maintain that secret or use multiple secrets if you have pipelines with multiple needs.
Then, you need to run:
git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic#github.com/<myproject>".insteadOf "https://github.com/<myproject>" before doing build/get.

Integrating Jenkins with Gitlab

I need to setup a build configuration in Jenkins so that whenever a build is triggered, I get my latest scripts from Gitlab and copy them to the target systems and run that script on the target.
I couldn't find any relevant info for integrating Gitlab to Jenkins. Are there any specific plugins that I could use?
I am using Jenkins version 2.158
Step by Step procedure for doing what you are looking for:
Add the location of the Script from GitLAB. (E.g.)
Run the script over the target machine.
While Building the job, you will get the code at the root (./) of the job's workspace. Copying and running the script over the target machine can be done by remote script executions. following are the cases we having in running script in the remote machine
Windows (jenkins) to windows - use psexec.exe
Windows (Jenkins) to linux - use plink.exe which is command line putty
Linux (Jenkins) to linux - use SCP and SSH
Linux to Windows - use ansible for windows.
E.g,.
$ scp script.sh remote_username#10.10.0.2:/remote/directory
$ ssh -t remote_username#10.10.0.2 /remote/directory/script.sh
All the best.
Integration between Git Repository Management (github, gitlab,bitbucket, etc) and Jenkins has the following steps :
Developer push some source code (java, php, nodejs, etc) to the Git Repository Management.
The Git Repository Management detects this event and notify to some public http endpoint in your Jenkins. Currently webhook is the most recommended way to implement this notification.
Jenkins receive the http post request(from bitbucket for example) and using some plugin or configurations , Jenkins try to determine or get the basic devops parameters like : branch name, commit author, commit message, technology, etc
Whit the extracted devops parameters, Jenkins launchs a preconfigured job. This job use the previously extracted values to build, compile, zip, install or to do whatever is necessary to startup your application.
If you want to implement this flow, check this post:
https://jrichardsz.github.io/devops/devops-with-git-and-jenkins-using-webhooks
Also, if you need. I will gladly to show you a basic integration using some git repository management and jenkins . Just contact me.

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