Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

[JENKINS-31086] Add useDefaultExcludes option to stash #266

Merged
merged 1 commit into from Dec 8, 2015

Conversation

abayer
Copy link
Member

@abayer abayer commented Dec 5, 2015

JENKINS-31086

Defaults to true, meaning use Ant default excludes for
DirScanner.Glob. If false, don't use the default excludes, to pick up
files like .gitignore etc.

@reviewbybees

@ghost
Copy link

ghost commented Dec 5, 2015

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@abayer abayer closed this Dec 5, 2015
@abayer abayer reopened this Dec 5, 2015
@abayer
Copy link
Member Author

abayer commented Dec 5, 2015

Closing/reopening - those failures look spurious to me.

@abayer
Copy link
Member Author

abayer commented Dec 5, 2015

Can't reproduce this locally - had one test failure on org.jenkinsci.plugins.workflow.steps.ExecutorStepTest.buildShellScriptAcrossDisconnect(org.jenkinsci.plugins.workflow.steps.ExecutorStepTest), but that looks transient as well. Could be a concurrency issue?

@abayer
Copy link
Member Author

abayer commented Dec 7, 2015

Rebased.

@abayer
Copy link
Member Author

abayer commented Dec 7, 2015

Woo, and now the tests actually decided to pass. =)

" }\n" +
" writeFile file: 'at-top', text: 'ignored'\n" +
" stash name: 'from-top', includes: 'elsewhere/'\n" +
" semaphore 'ending'\n" +
Copy link
Member

Choose a reason for hiding this comment

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

🐜 These three lines serve no apparent function in this test case and could have been skipped along with the asserts about StashManager.

Copy link
Member Author

Choose a reason for hiding this comment

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

Which three lines? Not sure what you're referring to.

Copy link
Member

Choose a reason for hiding this comment

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

writeFile file: 'at-top', text: 'ignored'
stash name: 'from-top', includes: 'elsewhere/'
semaphore 'ending'

all copied from smokes but not testing anything novel here. The only thing this test case needs to check is that subdir/.gitignore was stashed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to keep the stash - I like having the test first stash without default excludes and then do a second stash with default excludes enabled to make sure it's covering both options.

Copy link
Member

Choose a reason for hiding this comment

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

But the second stash is not even including subdir, so it is not testing the implicit useDefaultExcludes: true.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it is - the unstash is within dir('elsewhere'), and the original stash is done from within subdir, so we're not actually ever stashing the directory, just its contents.

Copy link
Member

Choose a reason for hiding this comment

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

You could, for example, do something like

dir('subdir') {stash 'stripped'}
//
unstash 'stripped'
echo "have .gitignore? ${fileExists '.gitignore'}"

and assert that it prints

have .gitignore? false

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, ok. That is simpler. Reworking it.

@abayer
Copy link
Member Author

abayer commented Dec 7, 2015

Addressed comments, re-pushed.

" stash name: 'from-top', includes: 'elsewhere/'\n" +
"}", true));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
assertEquals("{from-top={elsewhere/other=more}, whatever={.gitignore=whatever, other=more}}", StashManager.stashesOf(b).toString());
Copy link
Member

Choose a reason for hiding this comment

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

🐛 this is not going to work reliably. The build might have completed (deleting the stash) by the time you hit this line.

My suggestion was to delete both the calls to StashManager and SemaphoreStep, not just one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, now I get where you were going and have a new version about to get pushed.

Copy link
Member Author

Choose a reason for hiding this comment

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

FYI, to get this to work, I did need to create a second file so that the stash with implicit useDefaultExcludes doesn't error out due to no files to stash.

@abayer
Copy link
Member Author

abayer commented Dec 7, 2015

Yet more addressing and pushing!

import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

import static org.junit.Assert.assertEquals;
Copy link
Member

Choose a reason for hiding this comment

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

FWIW usual code style is to use static imports for these.

Copy link
Member Author

Choose a reason for hiding this comment

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

Wildcard, you mean? Ok.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, yes, static wildcard imports.

@jglick
Copy link
Member

jglick commented Dec 7, 2015

🐝

@abayer
Copy link
Member Author

abayer commented Dec 7, 2015

Hopefully one last round of addressing comments. =)

@abayer
Copy link
Member Author

abayer commented Dec 7, 2015

fyi, https://jenkins.ci.cloudbees.com/job/plugins/job/workflow-plugin/1955/ is the relevant build for the current state.

@jglick
Copy link
Member

jglick commented Dec 7, 2015

🐝

@abayer
Copy link
Member Author

abayer commented Dec 7, 2015

Fixed comment.

@jglick
Copy link
Member

jglick commented Dec 7, 2015

🐝

Defaults to true, meaning use Ant default excludes for
DirScanner.Glob. If false, don't use the default excludes, to pick up
files like .gitignore etc.
@abayer
Copy link
Member Author

abayer commented Dec 8, 2015

Rebased, merging.

abayer added a commit that referenced this pull request Dec 8, 2015
[JENKINS-31086] Add useDefaultExcludes option to stash
@abayer abayer merged commit 68e4b32 into jenkinsci:master Dec 8, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants