Jenkins Job DSL always creates a git tag for freestyle jobs using the git plugin - jenkins-job-dsl

I am creating a freestyle job with the Jenkins Job DSL. It appears to create a git tag every time. The default for scm -> git -> createTag appears to be "false", but this is deprecated. Was this turned ON elsewhere?
My code snippet is as follows (I added the createTag line to try to fix it, but it creates the add tag in "additional behaviors" anyway). Suggestions on how to fix?
scm {
git(buildRepoName, branchName) {
createTag(false)
}
}

If you use the git method with a closure parameter, the "create tag" option is disabled by default. See the API Viewer for details. See also JENKINS-33482.
job('example') {
scm {
git {
remote {
url('https://github.com/jenkinsci/job-dsl-plugin.git')
}
branch('master')
}
}
}

Related

ignoreCommitterStrategy is not working in mutibranch job-dsl generator job

enter code hereI'm trying to implement ignoreCommitterStrategy approach via multibranch generator job (i.e, job-dsl way)
I'm trying to implement ignoreCommitterStrategy approach via multibranch generator job (i.e, job-dsl way)
since we have too many existing multibranch-pipeline jobs and I try to achieve ignorecommitter stragegy inside branchsources of dsl.
After running seed job (i.e., multibranch generator job) I could see ignoreCommiter Strategy updated in existing multibranch pipeline jobs but still ignored author is not added. It means at this moment inside multibranch pipeline jobs -> config I have to manually click Add button and add ignored author list which is bit painful as we have many jobs.
buildStrategies {
ignoreCommitterStrategy {
ignoredAuthors("sathya#xyz.com")
allowBuildIfNotExcludedAuthor(false)
}
}
Note: I even tried with "au.com.versent.jenkins.plugins.ignoreCommitterStrategy"
Expecting IgnoredAuthor to be added into existing multibranch pipeline jobs upon execution of multibranch generator job
Currently the build strategy can not be set by using Dynamic DSL because of JENKINS-26535. But a fix is currently in review and will hopefully be released soon.
The correct syntax would be
multibranchPipelineJob('example') {
branchSources {
branchSource {
buildStrategies {
ignoreCommitterStrategy {
ignoredAuthors('test#acme.org')
allowBuildIfNotExcludedAuthor(true)
}
}
}
}
}
Until the problem has been fixed, you can use a Configure Block to set the necessary options.

Goland not showing ec2 methods is there an indexer?

I just installed Goland and it worked fantastic for working with the AWS SQS package code completion. However, I tried adding the ec2 package from aws and its not showing me the methods attached. I cannot locate any code completion indexer which i thought would just reindex the code
Here's what my ec2 template looks like:
package awsbridge
import (
"github.com/aws/aws-sdk-go/service/ec2"
)
type EC2Handle struct {
client *ec2.EC2
}
var ec2Handle *EC2Handle
func NewEc2Handle() *EC2Handle {
session := GetSession()
ec2Service := ec2.New(session)
ec2Handle = &EC2Handle{
client: ec2Service,
}
return ec2Handle
}
func (e *EC2Handle) AcceptReservedInstancesExchangeQuote() {
input:=&ec2.//no methods showing AcceptReservedInstancesExchangeQuoteInput
}
Unfortunately this is a known issue, see https://youtrack.jetbrains.com/issue/GO-5793
The workaround for now is to open Help | Edit custom system properties and add there:
idea.max.intellisense.filesize=3000000

Jenkins DSL pipeline syntax for wrappers or publishers

I am using DSL Plugin 1.64. I have DSL script for generating jobs. generating pipeline jobs, somehow wrappers and publishers syntax are not working. I have already asked one question for wrappers, now I am trying to use publishers and its not working in pipeline job. I can not see for example groovyPostBuild step. even I can not not see a postbuild action in pipeline job, I don`t want to put this is pipeline jenkinsfile.
pipelineJob('Dump_File_Verification ') {
parameters {
stringParam('DUMP_BUCKET', 'xxxxxxxx')
}
logRotator(-1, 50, -1, -1)
configure {
it / definition / lightweight(true)
}
triggers {
cron('0 */6 * * *')
}
concurrentBuild(false)
definition {
cpsScm {
scm {
scriptPath ('Jenkinsfile')
git {
branches('*/dev')
remote {
url ('git#github.com:xxxxxxx.git')
credentials ('xxxxxxxx')
}
extensions{
cloneOptions {
noTags(true)
shallow(true)
timeout(30)
}
}
}
}
}
}
publishers {
groovyPostBuild('println "hello, world"', Behavior.MarkFailed)
}}
The Pipeline job type does not support publishers or post-build actions. It's a problem in Job DSL that the syntax is available and does not cause a runtime error. See JENKINS-31832 in the Jenkins bug tracker.

How can I generate incremental Maven build in Jenkins Job DSL?

I'm trying to generate what appears in my Jenkins Maven job under Advanced... as
Incremental build - only build changed modules
This is an XML node that's directly within <maven2-moduleset>.
I didn't find it in the API, so I thought I'd use configure, but I can't figure it out. From what I understand, this should work:
mavenJob('foo') {
rootPOM('foo/pom.xml')
goals('clean package')
configure { node ->
node {
incrementalBuild('true')
}
}
}
However, I get an Exception:
groovy.lang.MissingMethodException: No signature of method: groovy.util.Node.call() is applicable for argument types: (Generator$_run_closure1_closure14_closure16) values: [Generator$_run_closure1_closure14_closure16#1f7d8eff]
Possible solutions: wait(), name(), value(), any(), wait(long), any(groovy.lang.Closure)
What am I doing wrong?
In this case you must use the / operator in the configure block to create or update an element, see Transforming XML in the Job DSL wiki.
mavenJob('foo') {
rootPOM('foo/pom.xml')
goals('clean package')
configure { node ->
node / incrementalBuild(true)
}
}

Gradle: How do I publish a zip from a non-java project and consume it in a java project?

I have a multi-project setup. I created a non-java project whose artifact is a zip file that I will unzip in another project. So the idea is as below
my-non-java-project
build.gradle
------------
apply plugin: 'base'
task doZip(type:Zip) { ... }
task build(dependsOn: doZip) << {
}
artifacts {
archives doZip
}
some-java-project
build.gradle
------------
apply plugin: 'war'
configurations {
includeContent // This is a custom configuration
}
dependency {
includeContent project(':my-non-java-project')
}
task expandContent(type:Copy) {
// Here is where I would like get hold of the all the files
// belonging to the 'includeContent' configuration
// But this is always turning out to be empty. Not sure how do I publish
// non-java content to the local repository (as understood by groovy)
}
So, my question is, how do I publish the artifacts of a non-java project to the internal repository of groovy such that I can pick it up at another java-based project?
Not exactly sure what you're after, but here's a quick-and-dirty way to get access to the FileCollection of the :my-non-java-project:doZip task outputs:
project(":my-non-java-project").tasks.getByName("doZip").outputs.files
Note that the archives configuration is added by the Java plugin, not the Base plugin. But you can still define a custom configuration in my-non-java-project and add the artifact to it with the code in your OP:
//in my-non-java-project/build.gradle
configurations {
archives
}
artifacts {
archives doZip
}
Then you can access the task outputs via the configuration, like so (again, quick-and-dirty):
//in some-java-project/build.gradle
project(":my-non-java-project").configurations.archives.artifacts.files
Note that you can expand the content of your zip file using zipTree.
If you need to actually publish the zip produced by my-non-java-project, you can read about that here.