Jenkins DSL pipeline syntax for wrappers or publishers - jenkins-job-dsl

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.

Related

Is there any way to monitor Azure Synapse Pipelines execution?

In my project, I've a need where I need to show how Pipeline is progressing on custom Web Portal built in PHP. Is there any way in any language such as C# or Java through which I can list pipelines and monitor the progress or even log into Application Insights?
Are you labelling your queries with the OPTION (LABEL='MY LABEL') syntax?
This will make it easy to monitor the progress of your pipeline by querying sys.dm_pdw_exec_requests to pick individual queries (see last paragraph under link heading), and if you use a naming convention like 'pipeline_query' you can probably achieve what you want.
try
{
PipelineRunClient pipelineRunClient = new(new Uri(_Settings.SynapseExtractEndpoint), new DefaultAzureCredential());
run = await pipelineRunClient.GetPipelineRunAsync(runId);
while(run.Status == "InProgress" || run.Status == "Queued")
{
_Logger.LogInformation($"!!Pipeline {run.PipelineName} {runId} Status: {run.Status}");
Task.Delay(30000).Wait();
run = await pipelineRunClient.GetPipelineRunAsync(runId);
}
_Logger.LogInformation($"!!Pipeline {run.PipelineName} {runId} Status: {run.Status} Runtime: {run.DurationInMs} Message: {run.Message}");
}

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.

Webjob always publishes as Continuous and not Triggered

I have an Azure WebJob which I am publishing from visual studio 2017 to a Standard S1 App Service, the WebJob should be Triggered by CRON but always publishes as Continuous and I cannot figure out what I have done wrong (two other WebJobs publish fine)
I have the App Service set to 'Always On' in application settings
I have a settings.job file in the root with my schedule
{
"schedule": "0 3 5 * * 1-5"
}
My Program class
namespace EventPushUpdater
{
using Microsoft.Azure.WebJobs;
using MBL.AzureKeyVaultHelpers;
internal class Program
{
private static void Main()
{
Properties.Settings s = Properties.Settings.Default;
IKeyVault kv = new KeyVaultHelper(s.ClientId, s.ClientKey, s.KeyVaultRoot);
var config = new JobHostConfiguration();
config.DashboardConnectionString = kv.GetSecretValue(s.DashboardConnectionString);
config.StorageConnectionString = kv.GetSecretValue(s.DashboardConnectionString);
var host = new JobHost(config);
host.Call(typeof(Functions).GetMethod("PushEvents"), new { keyVault = kv });
}
}
}
And the function being called
public class Functions
{
[NoAutomaticTrigger]
public static void PushEvents(IKeyVault keyVault)
{
// do stuff
}
}
The first time you chose 'Publish as a WebJob', it asks you if you want Continuous or On Demand (which includes scheduled):
If you picked the wrong choice, simply delete webjob-publish-settings.json under Properties, and try again.
As an aside, your code is overly complex as you're needlessly using WebJobs SDK. Instead, your code can simply be:
static void Main()
{
// Do Stuff
}
You can switch between 'Continuous' and 'Triggered' modes by editing the webjob-publish-settings.json file that is found within the Properties folder of your WebJob project.
In this json file you can set "runMode:" to either Continuous or OnDemand (triggered) :
Continuous
OnDemand
Have you set { "is_singleton": true } in your settings.job?
If so you cannot run more than one instance of your WebJob. If you publish and run your WebJob to the Azure cloud you cannot never run it locally unless you use a different storage account.
Azure Webjob timer trigger does not fire

Jenkins Job DSL always creates a git tag for freestyle jobs using the git plugin

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')
}
}
}

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)
}
}