Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<properties>
<changelist>999999-SNAPSHOT</changelist>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.492</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<jenkins.baseline>2.504</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
<useBeta>true</useBeta>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
</properties>
Expand Down Expand Up @@ -54,6 +54,22 @@
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<!-- TODO: https://github.com/jenkinsci/workflow-api-plugin/pull/417 -->
<!-- TODO: Remove when included in BOM -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>1397.v02e97a_30f3ce</version>
</dependency>
<dependency>
<!-- TODO: https://github.com/jenkinsci/workflow-api-plugin/pull/417 -->
<!-- TODO: Remove when included in BOM -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>1397.v02e97a_30f3ce</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -116,6 +132,12 @@
<version>2.31.33</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssooidc</artifactId>
<version>2.31.33</version>
<scope>test</scope>
</dependency>
Comment on lines +135 to +140
Copy link
Member Author

@dwnusbaum dwnusbaum Jul 25, 2025

Choose a reason for hiding this comment

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

I needed this to do basic testing directly against the AWS credentials available in my organization. It doesn't work for testing stuff related to the agent role assumption logic (seems like it should be possible with AWS_CHAINED_ROLE, but I couldn't quite get that working after spending a few minutes with it, but will take another look at it next week), and here I am not changing any of that logic anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I confirmed that this is required even after getting AWS_ROLE to work (problem was that I was trying to use the display name instead of the ARN for the role).

</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
}
if (nodeId != null && JenkinsJVM.isJenkinsJVM()) {
// Note that this does not necessarily shut down the AWSLogs client; that is shared across builds.
PipelineBridge.get().close(logStreamNameBase, buildId);
PipelineBridge.close(logStreamNameBase, buildId);

Check warning on line 154 in src/main/java/io/jenkins/plugins/pipeline_cloudwatch_logs/CloudWatchSender.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 154 is not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,21 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.log.BrokenLogStorage;
import org.jenkinsci.plugins.workflow.log.LogStorage;
import org.jenkinsci.plugins.workflow.log.LogStorageFactory;
import org.jenkinsci.plugins.workflow.log.LogStorageFactoryDescriptor;

/**
* Binds CloudWatch to Pipeline logs.
*/
@Extension
public final class PipelineBridge implements LogStorageFactory {

static {
// Make sure JENKINS-52165 is enabled, or performance will be awful for remote shell steps.
System.setProperty("org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep.USE_WATCHING", "true");
}

private static final Logger LOGGER = Logger.getLogger(PipelineBridge.class.getName());

private final Map<String, TimestampTracker> timestampTrackers = new ConcurrentHashMap<>();
private final Map<String, LogStorageImpl> impls = new ConcurrentHashMap<>();

@Override
public LogStorage forBuild(FlowExecutionOwner owner) {
final String logStreamNameBase;
Expand All @@ -82,18 +75,38 @@
return forIDs(logStreamNameBase, buildId);
}

static PipelineBridge get() {
return ExtensionList.lookupSingleton(PipelineBridge.class);
static LogStorage forIDs(String logStreamNameBase, String buildId) {
var descriptor = ExtensionList.lookupSingleton(PipelineBridge.DescriptorImpl.class);
return descriptor.impls.computeIfAbsent(logStreamNameBase + "#" + buildId, k -> new LogStorageImpl(logStreamNameBase, buildId, descriptor.timestampTrackers));
}

LogStorage forIDs(String logStreamNameBase, String buildId) {
return impls.computeIfAbsent(logStreamNameBase + "#" + buildId, k -> new LogStorageImpl(logStreamNameBase, buildId, timestampTrackers));
static void close(String logStreamNameBase, String buildId) {
var descriptor = ExtensionList.lookupSingleton(PipelineBridge.DescriptorImpl.class);
descriptor.impls.remove(logStreamNameBase + "#" + buildId);

Check warning on line 85 in src/main/java/io/jenkins/plugins/pipeline_cloudwatch_logs/PipelineBridge.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 79-85 are not covered by tests
}

void close(String logStreamNameBase, String buildId) {
impls.remove(logStreamNameBase + "#" + buildId);
@Extension
@Symbol("amazonCloudWatchLogs")
public static class DescriptorImpl extends LogStorageFactoryDescriptor<PipelineBridge> {
static {
// Make sure JENKINS-52165 is enabled, or performance will be awful for remote shell steps.
System.setProperty("org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep.USE_WATCHING", "true");
}

private final Map<String, TimestampTracker> timestampTrackers = new ConcurrentHashMap<>();
private final Map<String, LogStorageImpl> impls = new ConcurrentHashMap<>();

@Override
public String getDisplayName() {
return "Amazon CloudWatch Logs";
}

@Override
public PipelineBridge getDefaultInstance() {
return new PipelineBridge();

Check warning on line 106 in src/main/java/io/jenkins/plugins/pipeline_cloudwatch_logs/PipelineBridge.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 106 is not covered by tests
}
}

private static class LogStorageImpl implements LogStorage {

private final String logStreamNameBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static void globalConfiguration() throws Exception {
}

@Override protected LogStorage createStorage() {
return PipelineBridge.get().forIDs(LOG_STREAM_NAME, id);
return PipelineBridge.forIDs(LOG_STREAM_NAME, id);
}

@Override protected Map<String, Level> agentLoggers() {
Expand Down
Loading