-
Notifications
You must be signed in to change notification settings - Fork 1
Add jenkins trigger file #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mdotb-moz
wants to merge
6
commits into
main
Choose a base branch
from
mb/jenkins-trigger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a532d61
Add jenkins trigger file
mdotb-moz abbfd46
Debug action
mdotb-moz 0e782ab
Add the jenkins secrets to the action
mdotb-moz 79c60c6
Add architecture image
mdotb-moz b3b403b
Add debug info
mdotb-moz 9674ed2
Add debug traces
mdotb-moz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| # Create milestone - Quick Guide | ||
|
|
||
| The automation connects GitHub Actions → Bitrise →TestRail → Slack. | ||
| Checks Bitrise for new successful iOS release tags. | ||
|
|
||
| Detects whether: | ||
| - A new mayor version was released (e.g., 145.0), or | ||
| - A new RC build was generated (e.g., 145.3 RC4). | ||
| - Automatically triggers milestone creation in TestRail. | ||
| - Creates test runs for smoke tests. | ||
| - Sends release notifications to Slack. | ||
|
|
||
|
|
||
|  | ||
|
|
||
| Link to the documentation: https://docs.google.com/document/d/1LNhfbO7MYoY-nBRM0Dz22PO91SJjNLYyr1fhCuXNZe0/edit?tab=t.0 | ||
|
|
||
|
|
||
| # Jenkins Remote Job Trigger - Quick Guide | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Mac with Jenkins installed locally | ||
| - SSH access to the Mac | ||
| - Java installed on the Mac | ||
|
|
||
| ### Check/Install Java | ||
| ```bash | ||
| # Check if Java is installed | ||
| java -version | ||
|
|
||
| # If not, install with Homebrew | ||
| brew install openjdk@17 | ||
| ``` | ||
|
|
||
| ## 1. Download Jenkins CLI | ||
| ```bash | ||
| # Connect to the Mac via SSH | ||
| ssh user@mac-ip | ||
|
|
||
| # Download jenkins-cli.jar | ||
| cd ~ | ||
| wget http://localhost:8080/jnlpJars/jenkins-cli.jar | ||
|
|
||
| # Or with curl | ||
| curl -O http://localhost:8080/jnlpJars/jenkins-cli.jar | ||
| ``` | ||
|
|
||
| ## 2. Generate an API Token in Jenkins if you don't have one | ||
|
|
||
| # We alredy have one api token in one password | ||
|
|
||
| 1. Open Jenkins: `http://localhost:8080` | ||
| 2. Click on your **user** (top right) | ||
| 3. Click **"Configure"** | ||
| 4. In the **"API Token"** section → Click **"Add new Token"** | ||
| 5. Name: "CLI-Access" | ||
| 6. Click **"Generate"** | ||
| 7. **Copy the token** (it is only shown once) | ||
|
|
||
| ## 4. Create the Script | ||
| ```bash | ||
| # Create the script on the Mac | ||
| nano ~/jenkins-trigger.sh | ||
| ``` | ||
|
|
||
| **Script contents:** | ||
| Copy the jenkins-trigger.sh file contained in this repo | ||
|
|
||
| **Give it execute permissions:** | ||
| ```bash | ||
| chmod +x ~/jenkins-trigger.sh | ||
| ``` | ||
|
|
||
| ## 5. Using the Script | ||
|
|
||
| ### From the Mac (local) | ||
| ```bash | ||
| # Job without parameters | ||
| ~/jenkins-trigger.sh MyJob | ||
|
|
||
| # Job with one parameter | ||
| ~/jenkins-trigger.sh MyJob BRANCH=main | ||
|
|
||
| # Job with several parameters | ||
| ~/jenkins-trigger.sh MyJob BRANCH=develop PHONE=iPhone VERSION=18.6 | ||
| ``` | ||
|
|
||
| ### From a remote machine (via SSH) | ||
| ```bash | ||
| # Job without parameters | ||
| ssh user@mac-ip "~/jenkins-trigger.sh MyJob" | ||
|
|
||
| # Job with parameters | ||
| ssh user@mac-ip "~/jenkins-trigger.sh MyJob BRANCH=main PHONE=iPhone" | ||
|
|
||
| # Multiple parameters | ||
| ssh user@mac-ip "~/jenkins-trigger.sh MyJob BRANCH=hotfix ENV=staging VERSION=2.0.1" | ||
| ``` | ||
|
|
||
| ## 6. View Logs | ||
| ```bash | ||
| # View the entire log | ||
| cat ~/jenkins-trigger.log | ||
|
|
||
| # View the last 10 executions | ||
| tail -10 ~/jenkins-trigger.log | ||
|
|
||
| # View only successful ones | ||
| grep "SUCCESS" ~/jenkins-trigger.log | ||
|
|
||
| # View only failed ones | ||
| grep "FAILED" ~/jenkins-trigger.log | ||
|
|
||
| # View today's executions | ||
| grep "$(date '+%Y-%m-%d')" ~/jenkins-trigger.log | ||
|
|
||
| # Search for a specific job | ||
| grep "MyJob" ~/jenkins-trigger.log | ||
|
|
||
| # View logs remotely | ||
| ssh user@mac-ip "tail -20 ~/jenkins-trigger.log" | ||
| ``` | ||
|
|
||
| ## 7. Useful Jenkins CLI Commands | ||
| ```bash | ||
| # List jobs | ||
| java -jar jenkins-cli.jar -s http://localhost:8080/ -http -auth "user:token" list-jobs | ||
|
|
||
| # View user information | ||
| java -jar jenkins-cli.jar -s http://localhost:8080/ -http -auth "user:token" who-am-i | ||
|
|
||
| # Trigger a job manually (without the script) | ||
| java -jar jenkins-cli.jar -s http://localhost:8080/ -http -auth "user:token" build "MyJob" -p PARAM1=value1 | ||
|
|
||
| # View console output of a build | ||
| java -jar jenkins-cli.jar -s http://localhost:8080/ -http -auth "user:token" console "MyJob" -n lastBuild | ||
| ``` | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Configuration | ||
| JENKINS_CLI="$HOME/jenkins-cli.jar" | ||
| JENKINS_URL="http://localhost:8080/" | ||
| JENKINS_USER="jenkins-username" | ||
| JENKINS_TOKEN="jenkins-token" | ||
| LOG_FILE="$HOME/jenkins-trigger.log" | ||
|
|
||
| # Logging function | ||
| log() { | ||
| echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE" | ||
| } | ||
|
|
||
| # Validation | ||
| if [ $# -lt 1 ]; then | ||
| echo "Uso: $0 <job_name> [PARAM1=value1] [PARAM2=value2]" | ||
| exit 1 | ||
| fi | ||
|
|
||
| JOB_NAME=$1 | ||
| shift | ||
|
|
||
| # Parameters | ||
| PARAMS=() | ||
| PARAMS_LOG="" | ||
| for arg in "$@"; do | ||
| PARAMS+=(-p "$arg") | ||
| PARAMS_LOG="$PARAMS_LOG $arg" | ||
| done | ||
|
|
||
| # Start Log | ||
| if [ -z "$PARAMS_LOG" ]; then | ||
| PARAMS_LOG="none" | ||
| fi | ||
|
|
||
| log "START | Job: $JOB_NAME | Params: $PARAMS_LOG" | ||
|
|
||
| # Execute | ||
| java -jar "$JENKINS_CLI" -s "$JENKINS_URL" -http -auth "$JENKINS_USER:$JENKINS_TOKEN" build "$JOB_NAME" $PARAMS | ||
|
|
||
| # Verify the result | ||
| if [ $? -eq 0 ]; then | ||
| log "SUCCESS | Job: $JOB_NAME | Job executed successfully" | ||
| echo "✓ Job $JOB_NAME started" | ||
| else | ||
| log "FAILED | Job: $JOB_NAME | Error running the job" | ||
| echo "✗ Error running the job $JOB_NAME" | ||
| exit 1 | ||
| fi |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this file README.md to be consistent with the rest of our repos.
Then, since it is inside Testrail folder and there are several actions we do here.. I would have two sections in this doc:
That way we have the README with the info needed for this Testrail section...
Does this make sense? Let me know your thoughts