Re: Plugin to add a custom build step.

2016-10-24 Thread Kul Bhushan Srivastava
Hi,

I am willing to put three windows batch command option (one in each 
optionalblock segment) in custom build step which I have developed.

Please find my config,jelly and java code below. What changes I need to 
done to achieve the same.

JAVA File

import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Builder;
import hudson.util.FormValidation;

public class BuildStepCreator extends Builder {

private String text, text1, text2;

public String getText(){
return text;
}
public String getText1(){
return text1;
}
public String getText2(){
return text2;
}


@DataBoundConstructor
public BuildStepCreator(OptinalTextBlock enableText, OptinalTextBlock1 
enableText1, OptinalTextBlock2 enableText2) {
this.text = (enableText != null) ? enableText.text : null;
this.text1 = (enableText != null) ? enableText1.text1 : null;
this.text2 = (enableText != null) ? enableText2.text2 : null;
}

public static class OptinalTextBlock {
private String text;
@DataBoundConstructor
public OptinalTextBlock(String text) {
this.text = text;
}
}
public static class OptinalTextBlock1 {
private String text1;
@DataBoundConstructor
public OptinalTextBlock1(String text1) {
this.text1 = text1;
}
}
public static class OptinalTextBlock2 {
private String text2;
@DataBoundConstructor
public OptinalTextBlock2(String text2) {
this.text2 = text2;
}
}

@Override
public boolean perform(hudson.model.AbstractBuild build, 
hudson.Launcher launcher, hudson.model.BuildListener listener) {
listener.getLogger().println("OptionalBlockSampleBuilder " + text);
return true;
}


@Extension
public static final class DescriptorImpl extends 
BuildStepDescriptor{

/*public FormValidation doCheckTask(@QueryParameter String value){
try{
if(value.equalsIgnoreCase(null) || 
value.equalsIgnoreCase("")){
return FormValidation.error("Invalid Details.");
}
}catch(Exception e){
return FormValidation.error("Error validating the form 
details.");
}
return FormValidation.ok();
}

public FormValidation doCheckGoal(@QueryParameter String value){
try{
Integer.parseInt(value);
}catch(Exception e){
return FormValidation.error("Please provide integer in the 
Goal.");
}
return FormValidation.ok();
}*/

@Override
public boolean isApplicable(Class 
jobType) {
// TODO Auto-generated method stub
return true;
}

@Override
public String getDisplayName() {
// TODO Auto-generated method stub
return "Job Orchectration";
}

}
}

config.jelly


  





  
  





  
  





  



On Monday, 24 October 2016 13:43:14 UTC+5:30, Kul Bhushan Srivastava wrote:
>
> Thanks for suggestions. I am able to build a custom build step now 
> successfully. Final code looks like this.
>
> JAVA File
>
> import org.kohsuke.stapler.DataBoundConstructor;
> import org.kohsuke.stapler.QueryParameter;
>
> import hudson.Extension;
> import hudson.model.AbstractProject;
> import hudson.tasks.BuildStepDescriptor;
> import hudson.tasks.Builder;
> import hudson.util.FormValidation;
>
> public class BuildStepCreator extends Builder {
> 
> private String text, text1, text2;
> 
> public String getText(){
> return text;
> }
> public String getText1(){
> return text1;
> }
> public String getText2(){
> return text2;
> }
> 
>
> @DataBoundConstructor
> public BuildStepCreator(OptinalTextBlock enableText, OptinalTextBlock1 
> enableText1, OptinalTextBlock2 enableText2) {
> this.text = (enableText != null) ? enableText.text : null;
> this.text1 = (enableText != null) ? enableText1.text1 : null;
> this.text2 = (enableText != null) ? enableText2.text2 : null;
> }
>
> public static class OptinalTextBlock {
> private String text;
> @DataBoundConstructor
> public OptinalTextBlock(String text) {
> this.text = text;
> }
> }
> public static class OptinalTextBlock1 {
> private String text1;
> @DataBoundConstructor
> public OptinalTextBlock1(String text1) {
> this.text1 = text1;
> }
>   

Re: Plugin to add a custom build step.

2016-10-24 Thread Kul Bhushan Srivastava
Thanks for suggestions. I am able to build a custom build step now 
successfully. Final code looks like this.

JAVA File

import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Builder;
import hudson.util.FormValidation;

public class BuildStepCreator extends Builder {

private String text, text1, text2;

public String getText(){
return text;
}
public String getText1(){
return text1;
}
public String getText2(){
return text2;
}


@DataBoundConstructor
public BuildStepCreator(OptinalTextBlock enableText, OptinalTextBlock1 
enableText1, OptinalTextBlock2 enableText2) {
this.text = (enableText != null) ? enableText.text : null;
this.text1 = (enableText != null) ? enableText1.text1 : null;
this.text2 = (enableText != null) ? enableText2.text2 : null;
}

public static class OptinalTextBlock {
private String text;
@DataBoundConstructor
public OptinalTextBlock(String text) {
this.text = text;
}
}
public static class OptinalTextBlock1 {
private String text1;
@DataBoundConstructor
public OptinalTextBlock1(String text1) {
this.text1 = text1;
}
}
public static class OptinalTextBlock2 {
private String text2;
@DataBoundConstructor
public OptinalTextBlock2(String text2) {
this.text2 = text2;
}
}

@Override
public boolean perform(hudson.model.AbstractBuild build, 
hudson.Launcher launcher, hudson.model.BuildListener listener) {
listener.getLogger().println("OptionalBlockSampleBuilder " + text);
return true;
}


@Extension
public static final class DescriptorImpl extends 
BuildStepDescriptor{

/*public FormValidation doCheckTask(@QueryParameter String value){
try{
if(value.equalsIgnoreCase(null) || 
value.equalsIgnoreCase("")){
return FormValidation.error("Invalid Details.");
}
}catch(Exception e){
return FormValidation.error("Error validating the form 
details.");
}
return FormValidation.ok();
}

public FormValidation doCheckGoal(@QueryParameter String value){
try{
Integer.parseInt(value);
}catch(Exception e){
return FormValidation.error("Please provide integer in the 
Goal.");
}
return FormValidation.ok();
}*/

@Override
public boolean isApplicable(Class 
jobType) {
// TODO Auto-generated method stub
return true;
}

@Override
public String getDisplayName() {
// TODO Auto-generated method stub
return "Job Orchectration";
}

}
}

config.jelly


  





  
  





  
  





  


On Tuesday, 18 October 2016 16:45:16 UTC+5:30, Daniel Beck wrote:
>
>
> > On 17.10.2016, at 20:07, Kul Bhushan Srivastava  > wrote: 
> > 
> > Please suggest. 
>
> I don't know what else is wrong. Compare what you did with the mvn hpi 
> plugin archetype, it basically does exactly what you're doing, and it 
> works. 
>
> mvn -U org.jenkins-ci.tools:maven-hpi-plugin:create 
>
> FWIW it seems insane to upload plugins you don't even know are working to 
> Jenkins. Just debug them locally. You won't have to restart Tomcat then to 
> apply changes. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/27bd4568-fa43-4fc8-86f8-68179eeb789b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Plugin to add a custom build step.

2016-10-18 Thread Daniel Beck

> On 17.10.2016, at 20:07, Kul Bhushan Srivastava  wrote:
> 
> Please suggest.

I don't know what else is wrong. Compare what you did with the mvn hpi plugin 
archetype, it basically does exactly what you're doing, and it works.

mvn -U org.jenkins-ci.tools:maven-hpi-plugin:create

FWIW it seems insane to upload plugins you don't even know are working to 
Jenkins. Just debug them locally. You won't have to restart Tomcat then to 
apply changes.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/21C79BD2-3319-44A1-B536-DBA9719A332F%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.


Re: Plugin to add a custom build step.

2016-10-17 Thread Kul Bhushan Srivastava
Hi Daniel,

I have made my changes as suggested by You. Now my java file looks like.

import hudson.task.Builder;
import org.kohsuke.stapler.DataBoundConstructor;

public class BuildStepCreation extends Builder{
private final String task;

// Fields in config.jelly must match the parameter names in the 
"DataBoundConstructor"

@DataBoundConstructor
public BuildStepCreation(String task) {
this.task = task;
}

/**
 * We'll use this from the config.jelly.
 */
public String getTask(){
return task;
}

@Extension //This indicates to Jenkins that this is an implementation 
of an extension point.

public static class Descriptor extends BuildStepDescriptor {



@Override
public boolean isApplicable(Class 
jobType) {
//return FreeStyleProject.class.isAssignableFrom(jobType);
// Indicates that this builder can be used with all kinds of 
project types.
return true;
}

@Override
public String getDisplayName() {
//This human readable name is used in the configuration screen.
return "Job Orchestration";
}
}
}

My *config.jelly* file looks like which sits in 
*com.oracle.siebel.jenkins.BuildStepCreation* under resources folder.


  

  


I am building a *.hpi *file from my workbenck(Eclipse) and uploading the 
same on the jenkins server instance running on tomcat through Manage 
Jenkins link.

The information in *index.jelly* about the plugin description is getting 
read by the Jenkins and it is displaying under Installed Plugins as well.

But the custom build step is not populating in the drop down list.

Please suggest.

On Monday, 17 October 2016 13:38:56 UTC+5:30, Daniel Beck wrote:
>
>
> > On 17.10.2016, at 08:23, Kul Bhushan Srivastava  > wrote: 
> > 
> > public String getTask() { 
> > @Extension 
> > public static class Descriptor extends 
> BuildStepDescriptor { 
>
> Correction, the descriptor (second listing) is there, but not done 
> correctly. 
>
> The static nested class needs to be a 'sibling' of getTask(), not a 
> 'child'. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/f73d33c0-6fd1-4ddf-b106-ffa4f550fed8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Plugin to add a custom build step.

2016-10-17 Thread Kul Bhushan Srivastava
Hi Daniel,

I have made my changes as suggested by You. Now my java file looks like.

import hudson.task.Builder;
import org.kohsuke.stapler.DataBoundConstructor;

public class BuildStepCreation extends Builder{
private final String task;

// Fields in config.jelly must match the parameter names in the 
"DataBoundConstructor"
@DataBoundConstructor
public BuildStepCreation(String task) {
this.task = task;
}

/**
 * We'll use this from the config.jelly.
 */
public String getTask(){
return task;
}

@Extension //This indicates to Jenkins that this is an implementation 
of an extension point.
public static class Descriptor extends BuildStepDescriptor {



@Override
public boolean isApplicable(Class 
jobType) {
//return FreeStyleProject.class.isAssignableFrom(jobType);
// Indicates that this builder can be used with all kinds of 
project types.
return true;
}

@Override
public String getDisplayName() {
//This human readable name is used in the configuration screen.
return "Job Orchestration";
}
}
}

My *config.jelly* file looks like which sits in 
*com.oracle.siebel.jenkins.BuildStepCreation* under resources folder.


  

  


I am building a *.hpi *file from my workbenck(Eclipse) and uploading the 
same on the jenkins server instance running on tomcat through Manage 
Jenkins link.

The information in *index.jelly* about the plugin description is getting 
read by the Jenkins and it is displaying under Installed Plugins as well.

But the custom build step is not populating in the drop down list.

Please suggest.

On Monday, 17 October 2016 13:38:56 UTC+5:30, Daniel Beck wrote:
>
>
> > On 17.10.2016, at 08:23, Kul Bhushan Srivastava  > wrote: 
> > 
> > public String getTask() { 
> > @Extension 
> > public static class Descriptor extends 
> BuildStepDescriptor { 
>
> Correction, the descriptor (second listing) is there, but not done 
> correctly. 
>
> The static nested class needs to be a 'sibling' of getTask(), not a 
> 'child'. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/1d1ca7c1-819f-4706-8d64-e0d20d9a3ada%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Plugin to add a custom build step.

2016-10-17 Thread Kul Bhushan Srivastava
Hi Daniel,

I have made my changes as suggested by You. Now my java file looks like.

package com.oracle.siebel.jenkins;

import hudson.task.Builder;
import org.kohsuke.stapler.DataBoundConstructor;

public class BuildStepCreation extends Builder{
private final String task;

// Fields in config.jelly must match the parameter names in the 
"DataBoundConstructor"
@DataBoundConstructor
public BuildStepCreation(String task) {
this.task = task;
}

/**
 * We'll use this from the config.jelly.
 */
public String getTask(){
return task;
}

@Extension //This indicates to Jenkins that this is an implementation 
of an extension point.
public static class Descriptor extends BuildStepDescriptor {



@Override
public boolean isApplicable(Class 
jobType) {
//return FreeStyleProject.class.isAssignableFrom(jobType);
// Indicates that this builder can be used with all kinds of 
project types.
return true;
}

@Override
public String getDisplayName() {
//This human readable name is used in the configuration screen.
return "Job Orchestration";
}
}
}

My *config.jelly* file looks like which sits in 
*com.oracle.siebel.jenkins.BuildStepCreation* under resources folder.


  

  


I am building a *.hpi *file from my workbenck(Eclipse) and uploading the 
same on the jenkins server instance running on tomcat through Manage 
Jenkins link.

The information in *index.jelly* about the plugin description is getting 
read by the Jenkins and it is displaying under Installed Plugins as well.

But the custom build step is not populating in the drop down list.

Please suggest.

On Monday, 17 October 2016 13:38:56 UTC+5:30, Daniel Beck wrote:
>
>
> > On 17.10.2016, at 08:23, Kul Bhushan Srivastava  > wrote: 
> > 
> > public String getTask() { 
> > @Extension 
> > public static class Descriptor extends 
> BuildStepDescriptor { 
>
> Correction, the descriptor (second listing) is there, but not done 
> correctly. 
>
> The static nested class needs to be a 'sibling' of getTask(), not a 
> 'child'. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/c5236d52-8401-4ad3-96fe-087a8e711d44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Plugin to add a custom build step.

2016-10-17 Thread Daniel Beck

> On 17.10.2016, at 08:23, Kul Bhushan Srivastava  wrote:
> 
> public String getTask() {
> @Extension
> public static class Descriptor extends BuildStepDescriptor {

Correction, the descriptor (second listing) is there, but not done correctly.

The static nested class needs to be a 'sibling' of getTask(), not a 'child'.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/5F81FD0D-D631-4656-84F5-2520F0B8E1C3%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.


Re: Plugin to add a custom build step.

2016-10-17 Thread Daniel Beck

> On 17.10.2016, at 08:23, Kul Bhushan Srivastava  wrote:
> 
> The java code looks like 

Follow the rest of the instructions. You're not done after the first listing, a 
third into the first section of the tutorial.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/7E114FD0-1CB3-4ACF-B00F-28F0A73D3405%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.


Re: Plugin to add a custom build step.

2016-10-17 Thread Kul Bhushan Srivastava
Hi Daniel,

Thanks for your response.

I am using the sample java code demonstrated in the following link 
https://wiki.jenkins-ci.org/display/JENKINS/Create+a+new+Plugin+with+a+custom+build+Step
 

 
to build my custom build step. POM.xml is same as described here except 
parent section version tag. In my case it is 1.420 instead of 1.400

I have did this change to resolve one of the ClassNotFound exception while 
using version 1.400

I have build the maven project using 
https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial for my Eclipse 
IDE.

The java code looks like 

import hudson.task.Builder;
import org.kohsuke.stapler.DataBoundConstructor;

public class BuildStepCreation extends Builder{
private final String task;

@DataBoundConstructor
public BuildStepCreation(String task) {
this.task = task;
}

public String getTask() {
@Extension
public static class Descriptor extends BuildStepDescriptor 
{

@Override
public boolean isApplicable(Class 
jobType) {
return FreeStyleProject.class.isAssignableFrom(jobType);
}

@Override
public String getDisplayName() {
return "Job Orchestration";
}
}
}
}

On Saturday, 15 October 2016 22:30:12 UTC+5:30, Daniel Beck wrote:
>
>
> > On 15.10.2016, at 17:36, Kul Bhushan Srivastava  > wrote: 
> > 
> > the same is not achieved 
>
> You need to provide much more information than this. 
>
> http://www.catb.org/~esr/faqs/smart-questions.html#beprecise 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/525f6f7f-d9fd-4af0-9dba-29b10282b7f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Plugin to add a custom build step.

2016-10-15 Thread Daniel Beck

> On 15.10.2016, at 17:36, Kul Bhushan Srivastava  wrote:
> 
> the same is not achieved

You need to provide much more information than this.

http://www.catb.org/~esr/faqs/smart-questions.html#beprecise

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/51B1015A-267F-4574-8121-C9867A062D81%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.