Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    jf1983
    @john-fletcher
    can someone give me the Job DSL script on generate freestyle job with allure plugin for reports
    Raddadi Mehdi
    @eclar
    hello, do you know where I could find an example of using the job dsl to get the projects from a github organization and create the multibranches pipelines ? :)
    Gordon Franke
    @gimler

    @eclar actually i have this

          organizationFolder('d060631') {
              description('Personal repository for Gordon Franke (d060631)')
              displayName('Gordon Franke')
              triggers {
                  periodic(2400)
              }
              organizations {
                  github {
                      repoOwner("badman")
                      apiUri("https://api.github.com")
                      credentialsId('github')
                      traits {
                          headWildcardFilter {
                              includes("jenkins-pipeline")
                              excludes("")
                          }
                      }
                  }
              }
              projectFactories {
                  workflowMultiBranchProjectFactory {
                      scriptPath("Jenkinsfile")
                  }
              }
          }

    now i hang on the behaviours i found thie following
    https://github.com/jenkinsci/configuration-as-code-plugin/blob/master/demos/jobs/bitbucket.yaml#L41

    sathya1104
    @sathya1104

    Hello team,
    ignoreCommitterStrategy (part of git plugin) doesn't pick ignoredAuthors from multibranch generator job (i.e, job-dsl way).

    Below is the code which I tried inside my seed job
    buildStrategies {
    ignoreCommitterStrategy {
    ignoredAuthors("sathya@xyz.com")
    allowBuildIfNotExcludedAuthor(false)
    }
    }

    Note: Had even tried with "au.com.versent.jenkins.plugins.ignoreCommitterStrategy"

    After running seed job (i.e., multibranch generator job) I could see ignoreCommiter Strategy reflecting in existing multibranch pipeline jobs but still ignoredAuthor is not added. It means at this moment inside multibranch pipeline jobs -> config I have to manually click on Add button and add ignored author list manually which is bit painful as we have many jobs.

    Any help on this is really appreciated.

    tschlue
    @tschlue
    Hi
    the multibranchPipelineJob option 'branchDiscoveryTrait ' in the branchSources doesn't work is there a trick?
    I get the following error:
    ERROR: Found multiple extensions which provide method branchDiscoveryTrait with arguments [jobs.JenkinsFileJob$_create_closure1$_closure3$_closure11$_closure12$_closure13$_closure14$_closure15@29dddaa]: [[com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait, jenkins.plugins.git.traits.BranchDiscoveryTrait, org.jenkinsci.plugins.github_branch_source.BranchDiscoveryTrait]]
    Jamie Jackson
    @jamiejackson

    i generated this with the xml to dsl plugin, but it doesn't work. it's the first seed job i've tried to create that has an "inline" pipeline definition: https://gist.github.com/jamiejackson/aea41c3358ab15217fd5139d78186450

    how do i get that to work?

    hmm, reading up, i suppose that this room is dead.
    Jamie Jackson
    @jamiejackson
    that works.
    dsakilesh
    @dsakilesh

    @jamiejackson @tschlue @sathya1104 @gimler @eclar @john-fletcher
    I need your suggestion here.
    JCasc traits configuration is needed for "scan by webhook" trigger in jenkins DSL. We are using bitbucket here.
    Currently we have periodic scan and we want to use the "scan by webhook" trigger function. Below is the periodic trigger syntax:

    it / 'triggers' << 'com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger'{
    spec ' *'
    interval "60000"
    }
    Could you please provide/suggest us the similar syntax for "scan by webhook" trigger? Thanks in advance!

    tschlue
    @tschlue
    @dsakilesh Sorry, I don't work with JCasc at the moment and can't help you.
    Michael
    @emanuelelevo_gitlab
    Hi
    do you guys know how to escape variables with curly brackets under shell? E.g.
    --junitxml="BUILD_\${BUILD_ID}_RESULTS.xml
    Its not enough:
    Caught unhandled exception with ID bffcbf9c-d4c3-4393-bc44-1c035b345b6b org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: script: 19: unexpected char: '\' @ line 19, column 70. adless true --junitxml="BUILD_\_RESULTS.
    version: job-dsl:1.77
    rtp
    @redturtlepower
    Hi! The docs (at https://github.com/jenkinsci/job-dsl-plugin/wiki/Migration) don't say how to specify the overrideUrl for the Bitbucket plugin.
    I have guessed the line "overrideUrl(...)". I haven't tested it yet...
    version: job-dsl: 1.77
    - script: >
          pipelineJob('hello-world-server') {
              properties{
                  pipelineTriggers{
                      triggers{
                          bitbucketPush()
                          overrideUrl('https://bitbucket.org/MyRepo/hello-world-server')
                      }
                  }
              }
              // ... the definition comes here       
          }
    rtp
    @redturtlepower
    FIgured out the real definition:
    triggers{
      bitbucketPush{
        overrideUrl('https://bitbucket.org/MyRepo/hello-world-server')
      }
    }
    Graeme Wilson
    @techlunacy
    hi with the job-dsl plugin how would i go about doing a git shallow clone with --no-single-branch set?
    Srikanth Jana
    @janasrikanth
    Hello All
    How do i add below parameter in dsl script
    image.png
    Srikanth Jana
    @janasrikanth
    or how do i add defauld sender email for that plugin
    Srikanth Jana
    @janasrikanth
    projectFrom will work ?
    Slaus Blinnikov
    @SlausB

    Hello! I'm running jenkins on localhost inside Docker container. Project to build doesn't have Jenkinsfile in it, so I have to provide it along with jenkins deployment, so I try to define the job like this:

    pipelineJob('my_job') {
        definition {
            cps {
                script(readFileFromWorkspace('/var/jenkins_home/jCasC/jobs/my_pipeline.jenkinsfile'))
                sandbox()
            }
        }
    }

    But getting error:

    java.lang.NullPointerException
        at javaposse.jobdsl.plugin.JenkinsJobManagement.locateValidFileInWorkspace(JenkinsJobManagement.java:423)

    I checked that file /var/jenkins_home/jCasC/jobs/my_pipeline.jenkinsfile IS there and Jenkins executable does have root access, so it shouldn't be permissions problem.
    When I replace readFileFromWorkspace('/var/jenkins_home/jCasC/jobs/my_pipeline.jenkinsfile') with source text itself - everything works fine. What could be the problem? How can I specify local-to-jenkins pipeline file in my pipeline job?

    Ioannis Triantafillou
    @ollandos

    Hi everyone! I have been hitting my head to the wall the past 4 days trying to configure Jenkins CasC to play well with jobdsl. I am a fan of IaC and we want everything to be done this way. My pain point is the following; I try to configure an organizationFolder and adjust the triggers -> githubBranches to my specification.

    jobs:
      - script: >
          organizationFolder('Hey guys!') {
            description("Hello!")
            displayName('Awesome org')
            triggers {
              githubBranches {
                spec("")
                triggerMode("HEAVY_HOOKS")
                abortRunning(true)
                cancelQueued(true)
                repoProviders {
                  githubPlugin{
                    cacheConnection(true)
                    manageHooks(true)
                    repoPermission("ADMIN")
                  }
                }
              }
            }
            // "Projects"
            organizations {
              github {
                repoOwner("my_org")
                credentialsId("some-creds")
                traits {
                  // Discovers branches on the repository.
                  gitHubBranchDiscovery {
                    // Determines which branches are discovered.
                    // 1 = Exclude branches that are also filed as PRs
                    strategyId(1)
                  }
                  gitHubPullRequestDiscovery {
                    // Determines how pull requests are discovered: Merging the pull request with the current target branch revision Discover each pull request once with the discovered revision corresponding to the result of merging with the current revision of the target branch.
                    // 1 = Merging the pull request with the current target branch revision
                    strategyId(1)
                  }
                  gitHubExcludeArchivedRepositories()
                  sourceWildcardFilter {
                    // Space-separated list of project name patterns to consider.
                    includes("a-repo")
                    excludes("")
                  }
                }
              }
            }
          }

    No matter how I tried adjusting this when trying to load this configuration I will get the following message:
    java.lang.ClassCastException: jenkins.branch.OrganizationFolder cannot be cast to hudson.model.Job

    I can validate that this error will occuer only when githubBranches are defined in the triggers section. I have scoured the web for an answer to this to no avail.
    If someone here has the knowledge and time to shine some light to this situation I would be forever grateful!

    dev-samples
    @dev-samples

    Using Jenkins 2.289.1 and Job DSL 1.77

    I use this for creating a multibranch pipeline job:

    multibranchPipelineJob("example") {
        branchSources {
            git {
                id("example1") 
                remote("${gitUrl}")
                credentialsId("${credentialsIdSSH}")
            }
        }
        triggers {
          cron('H/2 * * * *') // Branch indexing
        }
    
        orphanedItemStrategy {
            discardOldItems {
                numToKeep(20)
            }
        }
    
        factory {
            workflowBranchProjectFactory {
                scriptPath("${pathToJenkinsFile}")
            }
        }    
    }

    and based on the documentation:
    https://jenkinsci.github.io/job-dsl-plugin/#path/multibranchPipelineJob-triggers-cron

    I have added the above trigger for scanning for any new changes/branches.

    It actually seems to work (it runs a scan every 2nd minute) as expected but I am a bit puzzled that I don't see anything in the job configuration:
    https://i.ibb.co/stFgYcT/Selection-044.png

    both boxes are de-selected. So where is that trigger set or is it just ignored and falling back on some default value?