Jenkins Agent (macOS) #839
This file contains hidden or 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
| # --------------------------------------------------------------- | |
| # GitHub Actions workflow for Jenkins agent provisioning (macOS) | |
| # --------------------------------------------------------------- | |
| # | |
| # The GitHub Actions Cloud plugin triggers this workflow via | |
| # workflow_dispatch, passing the Jenkins URL, agent name, and | |
| # agent secret as inputs. | |
| # --------------------------------------------------------------- | |
| # A full list of software installed on the macOS runner can be found here: | |
| # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md | |
| name: Jenkins Agent (macOS) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| jenkins_url: | |
| description: 'Jenkins server URL (with trailing slash)' | |
| required: true | |
| agent_name: | |
| description: 'Jenkins agent name' | |
| required: true | |
| agent_secret: | |
| description: 'Jenkins agent secret' | |
| required: true | |
| jobs: | |
| agent: | |
| runs-on: macos-15-intel | |
| timeout-minutes: 360 # max 6 hours, adjust as needed | |
| steps: | |
| - name: Mask secret | |
| run: | | |
| secret=$(jq -r '.inputs.agent_secret' "$GITHUB_EVENT_PATH") | |
| echo "::add-mask::$secret" | |
| - name: Upgrade bash | |
| run: | | |
| brew install bash | |
| sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells' | |
| sudo dscl . -change /Users/runner UserShell /bin/bash /usr/local/bin/bash | |
| echo "/usr/local/bin" >> "$GITHUB_PATH" | |
| echo "SHELL=/usr/local/bin/bash" >> "$GITHUB_ENV" | |
| echo "BASH=/usr/local/bin/bash" >> "$GITHUB_ENV" | |
| /usr/local/bin/bash --version | |
| - name: Download Jenkins agent JAR | |
| run: | | |
| curl -sSfL --retry 3 --retry-delay 5 -o agent.jar \ | |
| "${{ inputs.jenkins_url }}jnlpJars/agent.jar" | |
| - name: Connect to Jenkins | |
| env: | |
| AGENT_SECRET: ${{ inputs.agent_secret }} | |
| run: | | |
| java -jar agent.jar \ | |
| -url "${{ inputs.jenkins_url }}" \ | |
| -secret "$AGENT_SECRET" \ | |
| -name "${{ inputs.agent_name }}" \ | |
| -workDir "/Users/runner/agent" \ | |
| -noReconnect |