-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #312 from jenkinsci/atual/fix-creds
Fix credentials not masked when `DurableTaskStep.USE_WATCHING` is true
- Loading branch information
Showing
5 changed files
with
236 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...le/injection/BuildScanInjectionGradleWithDurableTaskStepUseWatchingIntegrationTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package hudson.plugins.gradle.injection | ||
|
||
import hudson.plugins.gradle.BaseGradleIntegrationTest | ||
import hudson.plugins.gradle.BuildScanAction | ||
import hudson.slaves.DumbSlave | ||
import org.junit.Rule | ||
import org.junit.rules.TestRule | ||
import org.jvnet.hudson.test.FlagRule | ||
import spock.lang.PendingFeature | ||
import spock.lang.Unroll | ||
|
||
@Unroll | ||
class BuildScanInjectionGradleWithDurableTaskStepUseWatchingIntegrationTest extends BaseGradleIntegrationTest { | ||
|
||
private static final String MSG_INIT_SCRIPT_APPLIED = "Connection to Gradle Enterprise: http://foo.com" | ||
|
||
@Rule | ||
public final TestRule durableTaskStepRule = FlagRule.systemProperty("org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep.USE_WATCHING", "true") | ||
|
||
@PendingFeature | ||
def "cannot capture build agent errors in pipeline build if DurableTaskStep.USE_WATCHING=true"() { | ||
given: | ||
def gradleVersion = '8.1.1' | ||
gradleInstallationRule.gradleVersion = gradleVersion | ||
gradleInstallationRule.addInstallation() | ||
|
||
DumbSlave agent = createSlave('foo') | ||
def pipelineJob = GradleSnippets.pipelineJobWithError(j, gradleInstallationRule) | ||
|
||
when: | ||
// first build to download Gradle | ||
def firstRun = j.buildAndAssertSuccess(pipelineJob) | ||
|
||
then: | ||
j.assertLogNotContains(MSG_INIT_SCRIPT_APPLIED, firstRun) | ||
|
||
when: | ||
enableBuildInjection(agent, gradleVersion) | ||
withInjectionConfig { | ||
checkForBuildAgentErrors = true | ||
} | ||
def secondRun = buildAndAssertFailure(pipelineJob) | ||
|
||
then: | ||
secondRun.getAction(BuildScanAction) != null | ||
} | ||
|
||
def "credentials are always masked in logs"() { | ||
given: | ||
def secret = 'confidential' | ||
registerCredentials('my-creds', secret) | ||
|
||
def gradleVersion = '8.1.1' | ||
gradleInstallationRule.gradleVersion = gradleVersion | ||
gradleInstallationRule.addInstallation() | ||
|
||
DumbSlave agent = createSlave('foo') | ||
def pipelineJob = GradleSnippets.pipelineJobWithCredentials(j) | ||
|
||
when: | ||
// first build to download Gradle | ||
def firstRun = j.buildAndAssertSuccess(pipelineJob) | ||
|
||
then: | ||
j.assertLogContains('password=****', firstRun) | ||
j.assertLogNotContains(secret, firstRun) | ||
|
||
when: | ||
enableBuildInjection(agent, gradleVersion) | ||
withInjectionConfig { | ||
checkForBuildAgentErrors = true | ||
} | ||
def secondRun = j.buildAndAssertSuccess(pipelineJob) | ||
|
||
then: | ||
j.assertLogContains('password=****', secondRun) | ||
j.assertLogNotContains(secret, secondRun) | ||
} | ||
|
||
} |
Oops, something went wrong.