Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pipeline support #176

Merged

Conversation

adelcast
Copy link
Contributor

Add Pipeline support to TFS plugin

@adelcast adelcast force-pushed the dev/adelcast/add_pipeline_support branch from 022b57e to dab320b Compare September 22, 2017 21:52
@adelcast adelcast changed the title Dev/adelcast/add pipeline support tfs: add pipeline support Sep 22, 2017
@adelcast adelcast changed the title tfs: add pipeline support add pipeline support Sep 22, 2017
@yacaovsnc yacaovsnc requested review from olivierdagenais and removed request for olivierdagenais September 26, 2017 18:13
@@ -10,30 +10,31 @@
import java.util.ArrayList;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, you would remove the //CHECKSTYLE:OFF setting for the files that you modify and correct all the checkstyle warnings and errors in that file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imho a passing checkstyle run as part of the build is a minimal requirement for a contribution. Just get your IDE to format it correctly in an automated fashion. Or fix it manually if necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I removed the //CHECKSTYLE:OFF comments and fixed the fallout

new RemoveWorkspaceAction(workspaceConfiguration.getWorkspaceName()).remove(server);
nodeConfiguration.setWorkspaceWasRemoved();
nodeConfiguration.save();
Computer computer = workspaceFilePath.toComputer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add final where appropriate (checkstyle will find these)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

while (lastRun != null) {
AbstractBuild<?,?> build = lastRun;
AbstractBuild<?,?> build = (AbstractBuild)lastRun;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check the "instanceOf" lastRun before casting here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the comment I understood that node was only going to be NULL in Hudson core < 1.321, which doesn't support pipelines (so no Run class, just AbstractBuild). But I get that's a bit thin....I went ahead and added a check, just in case

@@ -19,16 +21,26 @@

private final List<ChangeSet> changesets;

@Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A TODO here with information on when we should remove these deprecated methods would help. For instance, should we remove them with the next major version release or can they be removed with the next minor release. A comment on who might be using these methods would also help clarify when they can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the methods is still being used by a few tests (added a comment). Removed the other.

Copy link
Contributor

@jpricket jpricket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good, but I had a few suggested changes.

@adelcast adelcast force-pushed the dev/adelcast/add_pipeline_support branch from dab320b to c2ae166 Compare September 28, 2017 22:39
@kvarec
Copy link

kvarec commented Oct 9, 2017

TeamFoundationServerScm.buildEnvironment required for envvars from checkout step

@adelcast adelcast force-pushed the dev/adelcast/add_pipeline_support branch from c2ae166 to eab95c6 Compare October 9, 2017 22:15
@adelcast
Copy link
Contributor Author

adelcast commented Oct 9, 2017

@kvarec good catch, fixed

Copy link
Contributor

@jpricket jpricket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes!

@kvarec
Copy link

kvarec commented Oct 12, 2017

According to https://issues.jenkins-ci.org/browse/JENKINS-36703 in method TeamFoundationServerScm.calcRevisionsFromBuild required to return SCMRevisionState.NONE instead of null
And then I have exception in polling log:
ERROR: polling failed in /var/lib/jenkins/jobs/MYJOB on build-node-machine
java.lang.ClassCastException: org.jenkinsci.plugins.workflow.job.WorkflowJob cannot be cast to hudson.model.AbstractProject
at hudson.plugins.tfs.TeamFoundationServerScm.compareRemoteRevisionWith(TeamFoundationServerScm.java:693)
at org.jenkinsci.plugins.workflow.job.WorkflowJob.poll(WorkflowJob.java:607)
at hudson.triggers.SCMTrigger$Runner.runPolling(SCMTrigger.java:594)
at hudson.triggers.SCMTrigger$Runner.run(SCMTrigger.java:640)
at hudson.util.SequentialExecutionQueue$QueueEntry.run(SequentialExecutionQueue.java:119)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

@adelcast adelcast force-pushed the dev/adelcast/add_pipeline_support branch 2 times, most recently from baba450 to f585335 Compare October 16, 2017 21:43
@adelcast
Copy link
Contributor Author

@kvarec yep, polling was busted since it was calling a deprecated method that required AbstractProject. I fixed it and ensure polling works as expected.

@kvarec
Copy link

kvarec commented Oct 17, 2017

And from https://ci.jenkins.io/blue/organizations/jenkins/Plugins%2Ftfs-plugin/detail/PR-176/8/pipeline/17:

  • tfs\src\main\java\hudson\plugins\tfs\JenkinsEventNotifier.java:0: error: File does not end with a newline.
  • tfs\src\main\java\hudson\plugins\tfs\listeners\JenkinsRunListener.java:0: error: File does not end with a newline.
  • tfs\src\main\java\hudson\plugins\tfs\SafeParametersAction.java:0: error: File does not end with a newline.
  • tfs\src\main\java\hudson\plugins\tfs\TeamFoundationServerScm.java:727:9: error: '{' at column 9 should be on the previous line.
  • tfs\src\main\java\hudson\plugins\tfs\TeamFoundationServerScm.java:741: error: Line has trailing spaces.
  • tfs\src\main\java\hudson\plugins\tfs\TeamPRPushTrigger.java:0: error: File does not end with a newline.

@adelcast adelcast force-pushed the dev/adelcast/add_pipeline_support branch from f585335 to 63fa9b1 Compare October 17, 2017 16:50
@adelcast
Copy link
Contributor Author

I went ahead and fixed the issues in \TeamFoundationServerScm.java, but I still get:

\tfs\src\main\java\hudson\plugins\tfs\JenkinsEventNotifier.java:0: error: File does not end with a newline.
tfs\src\main\java\hudson\plugins\tfs\listeners\JenkinsRunListener.java:0: error: File does not end with a newline.
tfs\src\main\java\hudson\plugins\tfs\SafeParametersAction.java:0: error: File does not end with a newline.
tfs\src\main\java\hudson\plugins\tfs\TeamPRPushTrigger.java:0: error: File does not end with a newline.

however, my change did not touch those files. Furthermore, looking at those files, they do end in a newline, so I am not sure what the linter is complaining about. Could this be a problem on the backend? not sure who can take a look at this.... @kvarec

@cdenneen
Copy link

@kvarec @adelcast is this build working again?

@jpricket
Copy link
Contributor

The build should be up and running again now. Please rebase/merge and try again.

@cdenneen
Copy link

@adelcast Can you add a doc or to README.md to give sample pipeline code that works with TFS and available parameters that can be used?

Alejandro del Castillo added 3 commits October 27, 2017 11:33
Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
Follow the guide on https://github.com/jenkinsci/pipeline-plugin/blob/master/DEVGUIDE.md.

Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
@adelcast adelcast force-pushed the dev/adelcast/add_pipeline_support branch from 63fa9b1 to 347da08 Compare October 27, 2017 16:35
@adelcast
Copy link
Contributor Author

@cdenneen is that really needed? The Snippet Generator already documents that for you. I looked at the Subversion/Git/Mercurial plugins and they don't explicitly document the pipeline usage (they rely on the Snippter Generator)

tfssyntax

@adelcast
Copy link
Contributor Author

@jpricketMSFT done, now we have all green, =)

@fuzzmz
Copy link

fuzzmz commented Nov 2, 2017

Any timeline on when we'll have this merged and a new version of the plugin released?

@jpricket
Copy link
Contributor

jpricket commented Nov 2, 2017

@fuzzmz - we hope to get this merged and released by the end of next week. Sorry for the delay.

@jpricket jpricket closed this Nov 2, 2017
@jpricket jpricket reopened this Nov 2, 2017
@jpricket
Copy link
Contributor

jpricket commented Nov 2, 2017

oops, didn't mean to close this.

@jpricket jpricket merged commit 21632ef into jenkinsci:master Nov 2, 2017
@calmzhu
Copy link

calmzhu commented Jan 21, 2018

So, after use pipeline to checkout tfs. How should we get the changeset since the functions returns a null .Does someone help please

@jpricket
Copy link
Contributor

You need to upgrade your version of Jenkins pipeline plugins. I think its 2.5 that fixes the problem where checkout returns null. After you upgrade your pipeline plugins, checkout should return a map with all the TFS environment variables you need.

@Tetradeus
Copy link

@adelcast, plz can you provide the documentation to trigger a release in vsts via pipeline ?

@raulney
Copy link

raulney commented Jan 15, 2019

@Tetradeus Did you manged to find any documentation on how to use this plugin via a Scripted/Declarative pipeline?

@Tetradeus
Copy link

nop, sorry.

@trivalik
Copy link

It seems to get enabled via set build trigger to SCM poll.
Source:
https://stackoverflow.com/a/37742811

I used this pipeline script which do this automatically if build is triggered manually.

pipeline {
    agent any
    
    triggers {
        pollSCM('H * * * *')
    }
   // remaining pipeline code ...

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants