jenkinsfile not found in multi module project - jenkins

I have a mvn project with a parent pom that is hosted in github. each module is a microservice that is buildable using mvn + docker.
I'm trying to configure a jenkins build of one of the modules but jenkins can't find Jenkinsfile becuase it's not in the root( assumption)
--Project
--moduleA
/jenkins/Jenkinsfile
When trying to configure a Pipeline (Using Jenkins blue ocean), Jenkins can't locate any Jenkinsfile in all the project's branches.

Related

Jenkins pipeline using maven project

I am trying to create a maven project pipeline it show me docker error although i already installed docker integration plugin in jenkins.

Jenkins Build Multiple projects in same repository

Previously we had a single monolith in GitLab repository and we used to build project in Jenkins using Jenkinsfile.
Now we are migrating it into multiple microservices and all reside in same GitLab repository. Is it possible to create pipelines for this type of setup or do we need to have each microservice in separate repository. If it is possible please point me to appropriate resources.
Each microservice can have its own Jenkinsfile, you have to tell to the Jenkins job the path of the Jenkinsfile if it is not located at the root path.
In your pipeline configuration job choose "Pipeline script from SCM" and set the "Script Path".
To only checkout the microservice you need, you can use in the "SCM" then "Additional Behaviours" the "Check out to a sub-directory" (then if the Jenkinsfile is now at the pseudo root path, you won't need to change the default "Script Path").
Yes it is possible to create pipelines to build/test/deploy from a single repository.
Use Declarative Pipeline in Jenkins.
You can have your microservices separated in different directories in a single repo and can build them all using a single pipeline using the stages & dir() option in Jenkinsfile. We're building close to 15 components from a single pipeline and push it to it's relevant artifactory from the same job. You can build non-dependent microservice components parallely too.
Documentation --> Jenkins Pipeline,Jenkinsfile

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

Build a Freestyle project using Jenkins Pipeline Job

I am trying to build a code which doesn't have a pom.xml. Also i want to deploy the same to artifactory. Is there a way to build such a project using pipeline job. I can use freestyle job for building the above project. But I was hoping if there is some way to achieve the same in pipeline job. Also I require the groovy script details for artifactory deployment of such kind of project in pipeline job. But the basic question I have is this even feasible?
UPDATE:
We have a freestyle project job in whcih which we package our freestyle code into .tar and then deploy to artifactory using Generic Artifactory Configuration.
Now I am trying to achieve the same using a pipeline job. I get the point that we can use shell script inside Groovy and can build a tar package but how to deploy the tar package to Artifactory using Pipeline job.
if you have only 1 file , you can use maven deploy option , and upload the file.
http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html

how to publish npm and maven in same maven reactor build using jenkins

Is there a way to publish to both an npm and a maven repository in a Jenkins job using one Maven2 reactor build pom file? The reactor build pom file contains two modules, one is a standard jar module and the other is a pom module that uses the exec plugin to call npm script targets that build the javascript project. Jenkins is configured to publish the maven dependencies to a corporate nexus server when build succeeds.
Project Layout:
project/
pom.xml
npm-module/
pom.xml
mvn-module/
pom.xml
This works great for the mvn-module and the npm-module builds. But now the trick is publishing the npm-module. Jenkins seems to only allow one publish to nexus post-build task.
Is there a way to do this? Can anyone explain how to set up Jenkins and a reactor build pom file that publishes both npm and maven modules to nexus?
I have an answer but would love to hear other ideas.
Jenkins Setup
create pre step "execute shell" to set npm _auth and email fields
npm config set _auth authhashstring
npm config set email some#email.com
add deploy to the maven "goals and options"
clean deploy -Dmaven.test.failure.ignore=true -Dfullclean=true
add "settings file from filesystem"
config/maven-settings.xml
Note: use the deploy goal instead of the jenkins "deploy artifacts to maven" post step because it does not use maven so your npm goals won't get called.
pom.xml Setup
In npm-module/pom.xml use frontend-maven-plugin and add executions to install node/npm and for npm publish. Make sure the publish is attached to the deploy phase. The instructions were good enough. Or you can use the exec plugin to execute the npm publish command on the deploy phase.
In mvn-module/pom.xml add the distributionManagement/snapshotRepository for your snapshots repo location.
maven settings.xml Setup
We put the maven settings.xml with the username and password in the project in a config directory, like this, mvn-module/config/maven-settings.xml. This is not ideal but we can replace the username and password w/ properties that can be set from maven/jenkins, I think. Jenkins will be configured to read this file from this location.
package.json Setup
In npm-module/package.json add the publishConfig/registry entry
"publishConfig": {
"registry": "url/nexus/content/repositories/npm-snapshots/"
}
Nexus Setup
The npm-snapshots hosted repository is set to allow redeploy. This is probably not a great idea but may be good enough for ongoing new development (not for releases obviously) and I was just trying to get the stack working. I will now need to work out the kinks.
So with that caveat aside, now the jenkins build will publish both java and node modules to their respective repositories from one Jenkins job using a top-level multi-module reactor pom.

Resources