In my Jenkins shared library, I have tons of groovy files in the /vars dir that define custom steps.
Many of them have multiple methods defined, and one method in a file may call another in the same file.
I am looking for a way to mock these local…
I'm using JenkinsPipelineUnit to test a pipeline. I define a custom step, like so:
// vars/getOnlineNodes.groovy
import jenkins.model.Jenkins
def call() {
Jenkins.get().nodes
.findAll { it.toComputer().isOnline() }
…
Currently I'm trying to register findFiles step.
My set up is as follows:
src/
test/
groovy/
TestJavaLib.groovy
vars/
javaLib.groovy
javaApp.jenkinsfile
Inside TestJavaApp.groovy I have:
...
import…
I'm trying to use jenkinsPipelineUnit to test a JenkinsFile that exists in the same git repository as my shared libraries. This Jenkinsfile references shared libraries located in src. It appears that I must commit my shared library changes before I…
The pipeline I'm trying to execute with JenkinsPipelineUnit have some imports and full path classes.
import org.jenkins.plugins.lockableresources.LockableResourcesManager
(...)
} catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException…
I'm trying to test a function in my Jenkins Script Pipeline.
void doSomeDockerThings(){
withCredentials([[$class: 'UsernamePasswordMultiBinding', creditialsId: 'my_creds', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
sh…
I am building a jenkins shared library (in groovy) and testing this with JenkinsPipelineUnit and in gradle. Running ./gradlew test jacocoTestReport runs fine, but the report is almost empty (just headers); no coverage is present.
Here are the…
I'm trying to write unit test to my Jenkins shared library using jenkins-pipeline-unit but for no success.
My project/directory structure is:
src/
└── org
└── company
├── JobData.groovy
├── Constants.groovy
├──…
I am trying to write unit tests for the custom steps in my Jenkins Shared Library. I've landed on using Gradle and JenkinsPipelineUnit (via the articles linked at the end of this post), and I am getting stuck on mocking the pwsh step that runs a…
I need to extract the first 3 characters of jenkinsfile parameter:
string(name: 'DB_Type', defaultValue: 'mysql' )
I tried the following but this did not work:
prefix=${params.db_type}
prefix=prefix.substring(0,2)
I have a Jenkins Pipeline that I would like to have a user input on to checkout a specific branch of their choosing. i.e. If I create a branch 'dev' and commit it in git,but Jenkins take a default branch(master)
Can any one please help me take a…
I am pretty new with using Jenkins pipelines and want to test my Jenkinsfiles and libraries. I found the JenkinsPipelinUnit but i am not able to let my tests running.
I am building a microservice with Maven and added the dependency for…
What I'm trying to do
I have a script that looks something like this:
def doStuff() {
println 'stuff done'
}
return this
I am loading this script in another script so that I have a Groovy Script object that I can call doStuff from. This is in…
I have this Jenkins Unit Test folder structure:
enter image description here
Code looks like this:
package com.db
import com.lesfurets.jenkins.unit.BasePipelineTest
import org.junit.Before
import org.junit.Test
class TestExample extends…