Coder Social home page Coder Social logo

mkobit / jenkins-pipeline-shared-library-example Goto Github PK

View Code? Open in Web Editor NEW
70.0 2.0 34.0 283 KB

Basic template example of a Jenkins Pipelines Shared Library that is tested using https://github.com/mkobit/jenkins-pipeline-shared-libraries-gradle-plugin

License: MIT License

Kotlin 18.21% Groovy 81.79%
jenkins jenkins-pipeline jenkins-pipeline-library jenkins-shared-library

jenkins-pipeline-shared-library-example's Introduction

Jenkins Pipeline Shared Library Gradle Plugin

CircleCI ZenHub Badge

Note
Contributions for examples are welcome!

Purpose

This repository is an example of a Jenkins Jenkins Pipeline Shared Library that uses the Shared Library Gradle Plugin for development and testing of shared libraries.

Explore this project by:

  • Importing into IntelliJ

  • Activating the resources/idea.gdsl to see how the Jenkins steps auto-completion works

  • Build, test, and run integration tests with ./gradlew build

  • See how test code is generated for simplifying tests (like com.mkobit.jenkins.pipelines.codegen.LocalLibraryRetriever)

jenkins-pipeline-shared-library-example's People

Contributors

mkobit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jenkins-pipeline-shared-library-example's Issues

Add a Groovy build.gradle example

@kleini commented on Thu Mar 15 2018

I would to stay at first with Groovy DSL in build.gradle files. Can you provide an example how to use your plugin in a build.gradle file?


@mkobit commented on Thu Mar 15 2018

I think this issue is better suited for https://github.com/mkobit/jenkins-pipeline-shared-library-example - is it alright if I migrate it there?


@mkobit commented on Thu Mar 15 2018

A few notes that may be helpful


@kleini commented on Thu Mar 15 2018

You're right. Migrate it.
Thanks for your hints. I will try to get it working for me and then contribute to your examples.


@kleini commented on Thu Mar 15 2018

I already got it working. Why did my first try to reference your plugin from my build.gradle file fail? No idea. I thought it was because it was written in Kotlin. The fault sits always in front of the computer!

How to activate the resources/idea.gdsl

Hi there,
I'm wondering if you can elaborate on this step Activating the resources/idea.gdsl to see how the Jenkins steps auto-completion works? I imported the project but can't find a way to get autocompletion to work. Thanks!

Request for guidance - Breaking the linkage to the obsoleting jcenter

Been having a few problems with the latest edition of your excellent and helpful plugin.
Getting intermittent failures resolving dependencies from jcenter.
I use this plugin to perform unit and integration testing a serveral Jenkins Shared Pipeline Libraries.

Can you offer any specific guidance about to go about removing the jcenter linkage and going with maven central?

java.lang.UnsupportedOperationException: no known implementation of class hudson.scm.SCM is named GitSCM

Hi,

I have wrote my code to test this vars declaritive pipeline,

def call(String var_codeRepoBranch, String var_codeRepoUrl) {
node {
try {
checkout([$class: 'GitSCM', branches: [[name: var_codeRepoBranch]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'peidong_bitbucket_eco', url: var_codeRepoUrl]]])
//git branch: var_codeRepoBranch, credentialsId: 'peidong_bitbucket_eco', url: var_codeRepoUrl
echo "first checkout done"
}
}
}

But I got following error in the integrationtest. After debug, I have found that the problem is that gradle sharedlibrary dependency has no plugin, "org.jenkinsci.plugins", "git".

But the latest plugin is in Maven repo, however the program is just trying to download it from jenkins-ci repo, and that repo has only very old git plugin here,
https://repo.jenkins-ci.org/public/org/jenkinsci/plugins/git/

I think the gradle plugin needs to be changed to download the jenkins-ci stuff from maven repo

Running on Jenkins in /tmp/j h2322993632165826436/workspace/project
[Pipeline] {
[Pipeline] checkout
[Pipeline] echo
first checkout failed
[Pipeline] retry
[Pipeline] {
[Pipeline] checkout
[Pipeline] }
ERROR: Execution failed
java.lang.UnsupportedOperationException: no known implementation of class hudson.scm.SCM is named GitSCM
at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:478)
at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:402)
at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:341)
at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:282)
at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:202)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:262)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:176)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1295)

Build script incompatible with Gradle 6

When I run any Gradle command from master (eef1ea2), I get the following warning:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.

If I re-run with --warning-mode all, I get the following output:

> Configure project :
The ProjectLayout.directoryProperty() method has been deprecated. This is scheduled to be removed in Gradle 6.0. Please use the ObjectFactory.directoryProperty() method instead.

If I upgrade Gradle to the latest version, 5.2, I get the same warnings.

Fix integration test

Starting at line 77 in test/integration/groovy/com/mkobit/libraryexample/ExampleSrcSpockSpec.groovy:

   then:
    // JenkinsRule has different assertion capabilities
    WorkflowRun run = rule.assertBuildStatusSuccess(futureRun)
    rule.assertLogContains('''
        [Pipeline] lock
        Trying to acquire lock on [myLock]
        Resource [myLock] did not exist. Created.
        Lock acquired on [myLock]
    '''.stripIndent(), run)
  }

should be

  then:
    // JenkinsRule has different assertion capabilities
    WorkflowRun run = rule.assertBuildStatusSuccess(futureRun)
    rule.assertLogContains('''
    [Pipeline] lock
    Trying to acquire lock on [myLock]
    Resource [myLock] did not exist. Created.
    Lock acquired on [myLock]
    '''.stripIndent(), run)
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.