Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .expeditor/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pipelines:
- HAB_NONINTERACTIVE: "true"
- HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true"
- habitat/test:
public: true
description: Execute tests against the habitat artifact
definition: .expeditor/habitat-test.pipeline.yml
env:
Expand Down
17 changes: 14 additions & 3 deletions habitat/plan.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,13 @@ function Invoke-After {
function Install-ChefOfficialDistribution {
Write-BuildLine "Installing chef-official-distribution gem from Artifactory"

# Test artifactory access and install chef-official-distribution if accessible
Write-BuildLine "******* Testing access to artifactory *******"
$artifactorySource = "https://artifactory-internal.ps.chef.co/artifactory/omnibus-gems-local/"

try {
$null = Invoke-WebRequest -Uri $artifactorySource -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop
Write-BuildLine "******* Artifactory is accessible, installing chef-official-distribution gem *******"
# Add Artifactory as gem source
gem sources --add $artifactorySource
if ($LASTEXITCODE -ne 0) {
Expand All @@ -127,11 +131,18 @@ function Install-ChefOfficialDistribution {
throw "Failed to install chef-official-distribution gem"
}

Write-BuildLine "Successfully installed chef-official-distribution"
# Verify chef-official-distribution installation
Write-BuildLine "******* Verifying chef-official-distribution installation *******"
gem list chef-official-distribution
If ($lastexitcode -ne 0) {
Exit $lastexitcode
} else {
Write-BuildLine "chef-official-distribution gem installed successfully"
}
}
catch {
Write-Error "Error installing chef-official-distribution: $_"
exit 1
Write-BuildLine "******* Artifactory is not accessible, skipping chef-official-distribution installation *******"
Write-BuildLine "******* Error: $($_.Exception.Message) *******"
}
finally {
# Always clean up gem sources
Expand Down
24 changes: 19 additions & 5 deletions habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,23 @@ EOF
}

make_pkg_official_distrib() {
build_line "Installing chef-official-distribution gem"
gem source --add "https://artifactory-internal.ps.chef.co/artifactory/omnibus-gems-local/"
# Install to the Bundler-created ruby gem directory structure
gem install chef-official-distribution --no-document --install-dir "$GEM_HOME/ruby/${ruby_gem_version}"
gem sources -r "https://artifactory-internal.ps.chef.co/artifactory/omnibus-gems-local/"
# Test if artifactory-internal.ps.chef.co is reachable
build_line "Testing connectivity to artifactory-internal.ps.chef.co..."
artifactory_url="https://artifactory-internal.ps.chef.co/artifactory/omnibus-gems-local/"
if wget --spider --timeout=30 --tries=1 --quiet "$artifactory_url" > /dev/null 2>&1; then
build_line "Artifactory is reachable, proceeding with chef-official-distribution installation"
# Install to the Bundler-created ruby gem directory structure
local install_dir="$GEM_HOME/ruby/${ruby_gem_version}"
gem sources --add "$artifactory_url"
gem install chef-official-distribution --no-document --install-dir "$install_dir"
gem sources -r "$artifactory_url"

build_line "Verifying chef-official-distribution installation"
if ! GEM_HOME="$install_dir" GEM_PATH="$install_dir" gem list -i chef-official-distribution; then
build_line "Error: chef-official-distribution installation failed"
exit 1
fi
else
build_line "Artifactory is not reachable, skipping chef-official-distribution installation"
fi
}
Loading